Price value is printing on shop, category and single product page via get_price_html() function. get_price_html() is a method of WC_Product_Variable class. In this method have a filter “woocommerce_get_price_html”. You can customize the current price structure with this filter as per your requirement. In this tutorial I use this filter woocommerce_get_price_html and add the custom text… Continue Reading
filter
Edits the Add To Cart text on Single Product Page
How do you customize the default “Add to cart” text on single product page? You can easily do it without editing the core file. There have a filter “woocommerce_product_single_add_to_cart_text” for single product’s add to cart text. Change The Add to cart Text Adds Price Value in Add to cart Button Where are you add the… Continue Reading
Displaying Product Description Above The Summary in WooCommerce
Product description is showing at below the product summary. In this tutorial I am showing how you will display it above the product summary section (see the screenshot) Here is the steps You will add all custom PHP codes in your theme’s functions.php file or any other place. It is totally depending on you. Unset… Continue Reading
Hiding Cart Menu Item When Cart is Empty
I had an interesting question from a user who wants to hide the cart item from the menu when cart is empty. This tutorial will only work if you are using the WooCommerce plugin. I added the simple PHP snippets into my functions.php file. Here is the code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
<?php //* do not include this line /** * Hiding the cart menu item when cart is empty * * @author Paul * @license GPL 2.0+ */ function paul_nav_menu_items( $items, $menu ) { //* get the cart page id $cart_page_id = get_option( 'woocommerce_cart_page_id' ); if( ! empty( $cart_page_id ) ) { foreach( $items as $key => $item ) { if( $item->object_id === $cart_page_id && WC()->cart->is_empty() ) { unset( $items[ $key ] ); //* removing the cart menu item from list } } } return $items; } add_filter( 'wp_get_nav_menu_items', 'paul_nav_menu_items', 10, 2 ); |
There have a filter wp_get_nav_menu_items which is… Continue Reading
Replacing default "Starter Pro" menu with your site name at Dashboard
There have a filter hook “starter_admin_menu” for admin menu. You’ll just drop the following code in your custom-starter/custom-functions.php file and see the magic. Snippet
1 2 3 4 5 |
//* Change Default Menu with Site Name add_filter( 'starter_admin_menu', 'gd_admin_menu' ); function gd_admin_menu( $menu ) { return __( 'Genesis Developer', 'starter' ); } |
After adding the following code I am getting this:
How to change the "View Listing" text – AgentPress Listings Plugin
Lot of users are asking this question: How to modify the “View Listing” text?. Very simple way you can change the text. Just drop the following code in your functions.php file and see the magic.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
add_filter( 'gettext', 'agentpress_change_view_listings_text', 20, 3 ); /** * Change view listings text. * * @link http://codex.wordpress.org/Plugin_API/Filter_Reference/gettext * @see switch http://php.net/manual/en/control-structures.switch.php */ function agentpress_change_view_listings_text( $translated_text, $text, $domain ) { if ( ( 'agentpress-listings' == $domain ) || ( 'agentpress' == $domain ) ) { switch ( $translated_text ) { case 'View Listing' : $translated_text = __( 'Modified Text', 'agentpress-listings' ); break; } } return $translated_text; } |
“View Listing” text is replacing with “Modified Text”. Explain: Code is using the WordPress’s gettext() filter. This filter hook… Continue Reading
Adding categories and tags to pages
In this article I am showing how to add the category and tags to pages. First registering the category and tags taxonomy to “page” type by init and register_taxonomy_for_object_type functions. After adding this code “Categories” and “Tags” meta box will appear on Page Add/Edit Screen at Dashboard.
1 2 3 4 5 6 7 8 9 10 |
/** Enabling Categories and Tags Taxonomy for pages at Add/Edit Screen * * @since 1.0 * */ add_action('init', 'gd_register_category_tags_taxonomy_for_page'); function gd_register_category_tags_taxonomy_for_page() { register_taxonomy_for_object_type('post_tag', 'page'); register_taxonomy_for_object_type('category', 'page'); } |
Adding opening and closing footer markup. genesis_page_entry_footer_markup_open… Continue Reading
Creating Footer Copyright Text UI in Theme Settings page of Genesis Framework
Today one question is came out from my mind. Why we can’t change the default footer copyright text from Genesis Theme Settings page? Every time we are installing the “Simple Edit” plugin or manually adding few code in the functions.php file. So I thoroughly checked the Genesis Theme Settings php file and got 2 filter… Continue Reading
Dividing the Genesis Footer in 2 parts
I am dividing the Genesis Footer in 2 parts. I am filtering the “genesis_footer_output” function. I added the following the code in functions.php file
1 2 3 4 5 6 7 |
add_filter('genesis_footer_output', 'gd_footer_output', 10, 3); function gd_footer_output($output, $backtotop_text, $creds_text){ $new_output = '<div class="footer-left">' . $output . '</div>'; $new_output .= '<div class="footer-right">Website Design by <a href="https://genesisdeveloper.me" target="_blank">GENESISDEVELOPER.ME</div>'; return $new_output; } |
And added the following CSS in style.css file
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
.footer-left{ float: left; width: 48.717% text-align: left; } .footer-right{ float: right; width: 48.717% text-align: right; } @media only screen and (max-width: 600px){ .footer-left, .footer-right{ clear: both; float: none; text-align: center; width: 100%; } } |
I am getting this output