Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #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 7 years, 11 months ago by waveseven.
    #738188

    Hi 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,
    Ismael

    #738281

    Hi Ismael

    Thanks for your reply. That is BRILLIANT !!! Just what I needed.

    I LOVE THIS THEME !!!

    Many Thanks
    Regards
    Colin

    #738394

    Hi 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
    Colin

    #738804

    Hi!

    Thank you for the update. We adjusted the code a bit. Please try it again.

    Regards,
    Ismael

    #738835

    Hi Ismael

    The adjusted code works perfectly. Thanks again for all your help.

    Regards
    Colin

    #739225

    Hi 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,
    Rikard

    #739337

    Hi Rikard

    Everything seems to be working as we wanted it, thank you. The ticket can be closed.

    Many Thanks
    Regards
    Colin

    #740977

    Hi Colin,

    Thanks for letting us know :-)

    Please open a new thread if you should have any further questions or problems.

    Best regards,
    Rikard

Viewing 9 posts - 1 through 9 (of 9 total)
  • The topic ‘Display parent category name followed by sub category name as h1 title ?’ is closed to new replies.