- This topic has 5 replies, 3 voices, and was last updated 2 years, 9 months ago by David.
-
AuthorPosts
-
July 14, 2020 at 12:13 am #1362738Dean
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.
July 14, 2020 at 2:20 am #1362847DavidStaffCustomer SupportHi 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 );
July 15, 2020 at 3:08 am #1364076DeanI 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.
July 15, 2020 at 4:14 am #1364130DavidStaffCustomer SupportGlad to be of help and thanks for providing your final code
July 16, 2021 at 12:36 am #1857657KrisAnd what would be to code only for category pages?
July 16, 2021 at 5:07 am #1857824DavidStaffCustomer SupportHi there,
can you raise a new topic – and confirm that you want to remove the Archive Page title – not the product titles.
-
AuthorPosts
- You must be logged in to reply to this topic.