Remove word Category: before actual category name
Hi,
How can we hide the word category before the actual category, see https://www.hoddam.freshhq.co.uk/product-category/ready-mixed-concrete/
Where we just want to display Ready-Mixed Concrete, rather than Category: Ready-Mixed Concrete.
Thanks,
Darren
-
Hi Darren,
Thank you for reaching out to us.
Please make a child theme and add the following code to the functions.php
add_filter( 'get_the_archive_title_prefix', '__return_empty_string' );
Screencast: https://youtu.be/H_2mQBKeh_4
Please try this and let me know how it goes.
Best regards,
Ariel H.0 -
Hi, I'm afraid this doesn't seem to be working.
Do you have any other ideas?
Thanks,
0 -
Hi Darren,
Please also try this in your child theme, please add the following to functions.php
Screenshot: https://i.imgur.com/8XzkftF.png
add_filter( 'get_the_archive_title', 'so_remove_category_prefix' );
function so_remove_category_prefix( $title ) {
if ( is_product_category() ) {
$title = single_term_title( '', false );
}
return $title;
}
Best regards,
Ariel H.0 -
Hi there, Unfortunately that removed all the words, not just Category: Thanks,
0 -
Hi Darren,
Thank you for the update.
I have received a suggestion from my colleague regarding a simpler solution to address this issue. Instead of utilizing the Archive Title dynamic field, you can make use of the Category Description to remove the word “Category:” from the title.
This is demonstrated on this screencast: https://youtu.be/vKjwV1iK2z4
After this, you may need to adjust the margins and padding of the text element to ensure it fits well within your layout.If you have any further questions, please let us know.
Best regards,
Ariel H.0 -
Hi Ariel,
Thanks for this, as a work around it's a good idea. The problem we're having is that we have a description in the Category description which we are pulling through using a Brizy Template. So if we remove this and replace it with the category title we lose our product description from the Brizy Template.
There must be another way? It feels like there should be a simple solution although I'm coming up short. I imagine not many people want 'Category: Title' to show on these pages.
Thanks,
Eilidh
0 -
Hi Darren,
Unfortunately, there is no option in WooCommerce to change this, and most searches about this issue point to adding a code snippet to work around this limitation.
https://wordpress.org/support/topic/remove-category-archive-for-form-title/
The code I provided in my previous email worked in my test environment. However, to ensure that it functions correctly on your website, we may need to make some modifications specific to your current theme. Could you kindly provide us with the name or details of the theme you are using on your site?Best regards,
Ariel H.0 -
Hi Ariel, We're using Astra (Child Theme). We can provide login details if needed. Thanks, Darren
0 -
Hi Darren,
My staging site is using Astra Child Theme as shown in this screenshot—https://i.imgur.com/CcvcXY0.png
I used the same code snippet provided in one of my previous replies.If this doesn't work at your end, please add us as a user to your WordPress Dashboard and send the following details to: communitysupport@brizy.io
Community Post link: https://support.brizy.io/hc/en-us/community/posts/13391767506194
WordPress Admin URL:
Username
PasswordPlease make a full backup of your website as a precaution.
Best regards,
Ariel H.0 -
Hi Ariel,
I've added in the code again to functions.php and I can now see that only Category has been removed. See https://www.hoddam.freshhq.co.uk/product-category/concrete-paving/
So it's working!
Thanks for your help with this.
Darren0
Please sign in to leave a comment.
Comments
10 comments