[Resolved] Disable Content Title for Woocommerce Product Pages Not Working

Home Forums Support [Resolved] Disable Content Title for Woocommerce Product Pages Not Working

Home Forums Support Disable Content Title for Woocommerce Product Pages Not Working

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #1362738
    Dean

    I want to create a “Header” in GPP Elements which will also display the page title on all product pages. Therefore I would like to remove the default title. However, I am unable to remove it.

    As I couldn’t achieve the desired result on a live site, I created a fresh localhost site running only GP Theme, GPP plugin and Woocommerce plugin.

    I created a “Layout” in GPP Elements and under Disable Elements checked Content Title. I then set the Location to Product All products. This had no affect.

    So I edited an individual product and under Layout -> Disable Elements I again ticked Content Title. This also had no effect. The default product title is still being displayed.

    I am able to get this working just fine for regular pages, so the issue seems to only be present when trying to remove Woocommerce product page titles.

    For clarity, this is a fresh install on localhost. It is running the latest version of WordPress and all themes and plugins. I have installed only GP, GPP and Woocommerce and with only 1 item in Elements (the Layout described above).

    Unless I am missing something, it seems to me like this may be a bug?

    Thank you.

    #1362847
    David
    Staff
    Customer Support

    Hi there,

    Woo does things differently to you regular post types. In this case it uses its own template part to get the title. Whereas the GP layout element simply targets the core content title function.

    To remove it requires this bit of PHP:

    remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_title', 5 );

    #1364076
    Dean

    I had my suspicions that might be the case, but I thought I had used it on a woo product page in the past. I guess not. Thanks for looking up the right filter too :-).

    Very much appreciate your fast support!

    In case I or anyone else comes across this thread again and wishes to add this to a mu plugin. You need to wrap it in the correct action so it fires at the right time.

    /**
    * Remove product page default title as it is being added in a header element
    */
    function ls_remove_default_woo_product_title() {
        remove_action('woocommerce_single_product_summary', 'woocommerce_template_single_title', 5 );
    }
    add_action( 'woocommerce_before_single_product', 'ls_remove_default_woo_product_title' );

    Thanks David marking resolved.

    #1364130
    David
    Staff
    Customer Support

    Glad to be of help and thanks for providing your final code

    #1857657
    Kris

    And what would be to code only for category pages?

    #1857824
    David
    Staff
    Customer Support

    Hi there,

    can you raise a new topic – and confirm that you want to remove the Archive Page title – not the product titles.

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.