19 Comments

  • Henk says:

    I came to this code, based on yours:

    add_filter( ‘woocommerce_page_title’, ‘custom_woocommerce_page_title’);
    function custom_woocommerce_page_title( $page_title ) {
    if( $page_title == ” ) {
    return “some custom name”;
    }else{
    return $page_title;
    }
    }

    It could be used in case you don’t link the main (default) page of the WooCommerce shop to any page in WordPress, which results in a WooCommerce main page not showing any title at all. Hence the ($page_title == ”). My ‘else’ addition in the code forces other (category) pages in the shop to still show their original titles.

    I’m not a coder and hadn’t come to this solution without you. So thank you very much, I appreciate your posting.

  • Greg says:

    Hi,

    Great tips! And a potential life saver for me!

    Instead of keeping to a fixed page title as in Option 1, Terry is there a way to show the category of the respective product instead? Eg, if the product details page can display the Category the product belongs to as the page title..

    Can someone can help me.

    Thanks in advance!
    Greg

  • Greg says:

    Hi Terry,

    Its more like just the category [Product Category Name] will do.. however, it must be able to fetch the correct category the currently displayed product belongs to.. FYI, i only use 1 level category..

    Thanks terry, for responding..!

    Cheers

  • Fabio says:

    Hi Terry. thank you for your post. I’m using Jupiter Responsive Magazine Theme with Woocommerce. I want to change the default tile “Our Shop” in another title. I used your code in function.php changing Shop with Our Shop ma it’s no work. Any suggestions?
    Thanks in advance
    Fabio

  • Rafael says:

    Hello Terry. I appreciate what you did here. the one line code to hide the title is really smart. I´ve seen others saying you couldn´t do it that way, but you´re the man!

    I´d like to do one more thing on the shop page which is removing the text “showing all x results” that appears under the title. Do you have a code for that also?

  • LCG says:

    I get this error when I try to add this to my functions.php
    Warning: call_user_func_array() expects parameter 1 to be a valid callback, no array or string given in /home/****/public_html/wp-includes/plugin.php on line 214

    cant figure out what to do

  • LCG says:

    the code from above to remove shop title
    add_filter(‘woocommerce_show_page_title’,false);

    is there something missing from plugins php?

  • Jon Ryan says:

    Thanks Terry- that worked nicely.

  • Jake says:

    Hi, Im trying to work out a version of this code that will only alter the heading of product-tag archives. For example on this page:

    http://flyinglessons.co.uk/location/south-east-england/

    The product tag is ‘south east england’ but I need the title to read ‘Shop for Flying Lessons in South East England’. Is there a way to add the phrase ‘Shop for Flying Lessons in’ before the tag title on every product-tag archive page?

    Thanks,
    Jake

  • Mat says:

    For anyone getting the error:

    Warning: call_user_func_array() expects parameter 1 to be a valid callback, no array or string given in /*****/plugin.php on line 214

    Use this code instead:

    add_filter(‘woocommerce_show_page_title’,’sswoo_show_page_title’);
    function sswoo_show_page_title() {
    return false;
    }

  • Arif Uddin says:

    Mat is right on this.
    If you provide a bool value as parameter you’ll get a Warning like,
    “Warning: call_user_func_array() expects parameter 1 to be a valid callback, no array or string given in /*****/plugin.php on line 214”

    There is a shorthand option also.
    add_filter(‘woocommerce_show_page_title’, ‘__return_false’);
    __return_false is a WP defined function which return false.

  • Steve says:

    Hi Terry!

    My website has double headers on each page. The first header is ok but the second header which generated by Woocommerce is hidden by CSS ‘display:none;’. I wanna remove the Woocommerce header but when I’ve tryed to insert your code:
    add_filter(‘woocommerce_show_page_title’,false);

    but this is calls an Error:
    Warning: call_user_func_array() expects parameter 1 to be a valid callback, no array or string given in /web1/mcgtimber.co.uk/wp-includes/class-wp-hook.php on line 274

    Try to find ‘h1’ in a code:
    http://www.mcgtimber.co.uk/product/32mm-x-150mm-loglap-softwood-timber-cladding/

    What did I do wrong?

  • Steve says:

    Error is gone but add_filter doesn’t work. There are still two H1 tags on the page.

  • Steve says:

    I’ve found a solution.
    It is needed to remove one of actions which called in woocommerce/includes/wc-template-hooks.php.
    I added this string in my Functions.php and double H1 was gone:
    remove_action( ‘woocommerce_single_product_summary’, ‘woocommerce_template_single_title’, 5 );

  • Sean Oakes says:

    Hi,

    This is exactly what I need, but couldn’t get it to work. Got parse errors, which broke the site, and I had to erase the new code via FTP in order to restore. Any ideas?

Leave a Reply

Your email address will not be published. Required fields are marked *

WhatsApp chat Talk to Me