-
AuthorPosts
-
January 20, 2017 at 9:27 pm #736643
Hi
I need some help with the woocommerce page titles. At the moment the title bar shows the product sub category name. Which is great.
e.g. Page title is “Smooth Leather”But what I would like to do is also display the the parent category name
e.g Clean: Smooth Leather
(Parent Category is “Clean” Sub category is “Smooth Leather”)Is there a way to do this?
Many Thanks
Regards
Colin-
This topic was modified 8 years, 10 months ago by
waveseven.
January 25, 2017 at 8:35 am #738188Hi waveseven!
Thank you for using Enfold.
Are you referring to the theme’s default title container? Please add this filter in the functions.php file.
add_filter('avf_title_args','avf_title_args_mod', 10, 4); function avf_title_args_mod($args) { global $wp_query; $id = $wp_query->get_queried_object_id(); $parent = get_category_parents( $id ); $parent = explode("/", $parent); if(is_tax('product_cat') && $parent[0] != $args['title']) { $args['title'] = $parent[0] . ': ' . $args['title']; } return $args; }Best regards,
IsmaelJanuary 25, 2017 at 11:31 am #738281Hi Ismael
Thanks for your reply. That is BRILLIANT !!! Just what I needed.
I LOVE THIS THEME !!!
Many Thanks
Regards
ColinJanuary 25, 2017 at 3:09 pm #738394Hi Ismael
I’ve added in the code to the functions.php file and it works great. However, when I click on a Category from the menu that doesn’t have a subcategory it displays the Category name twice.
e.g Outdoor Range: Outdoor Range (see link in private content field)
Is there a way to fix this?
Many Thanks
Regards
ColinJanuary 26, 2017 at 10:04 am #738804Hi!
Thank you for the update. We adjusted the code a bit. Please try it again.
Regards,
IsmaelJanuary 26, 2017 at 11:19 am #738835Hi Ismael
The adjusted code works perfectly. Thanks again for all your help.
Regards
ColinJanuary 27, 2017 at 6:44 am #739225Hi Colin,
Glad we could help :-)
Please let us know if you should need any further help on the topic or if we can close it.
Best regards,
RikardJanuary 27, 2017 at 12:37 pm #739337Hi Rikard
Everything seems to be working as we wanted it, thank you. The ticket can be closed.
Many Thanks
Regards
ColinFebruary 1, 2017 at 5:17 am #740977 -
This topic was modified 8 years, 10 months ago by
-
AuthorPosts
- The topic ‘Display parent category name followed by sub category name as h1 title ?’ is closed to new replies.
