Custom Meta Title for Product Categories

  • Hi Rank Math team.
    I’m using Rank Math in my WooCommerce store. My store has many Products in many Categories.

    I want to setup custom Product Meta Title for each category. I mean all products in a Category will have same Meta Title Template. For example:

    – Products in the category “Widgets” will have Meta Title Template: “Buy %product_title% %category% 25% OFF”.
    – Product in the category “Tools” will have Meta Title Template: “Buy %product_title% XXXX %category% 25% OFF | %brand%”
    – If a category doesn’t have custom Meta Title Template, all products in it will use the Default Meta Title.

    How can I setup them in Rank Math?

    Thanks,
    Tommy

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hello,

    Thank you for contacting Rank Math and sorry for any inconvenience that might have been caused due to that.

    Right now we don’t offer that solution (but you should be able to achieve it by using some custom filters: https://rankmath.com/kb/filters-hooks-api-developer/#change-the-title.

    Looking forward to helping you. Thank you.

    ​​​​​​​

    Hello Alberto,
    Thank you for your support, I managed to write some conditions in PHP and put it in your provided custom filters, and it is working as I wanted now.

    function custom_meta_title_override() {
    if (is_product()) {
    	global $product;
    	$id = $product->get_id();
    	$name = $product->get_title();
    	if (has_term( 'special-shaped', 'product_cat', $id)) {
        	return 'Buy ' . $name . ' Special Shaped Diamond Painting Kit at 30% Off | PNC'; }
    	else if (has_term( 'diamond-painting-kits', 'product_cat', $id)) {
        	return 'Buy ' . $name . ' Diamond Painting Kit at 30% Off | PNC'; }
    	else {
    		return 'Buy ' . $name . ' at 30% Off | PNC'; 
    		}
      } 
    } 
    add_filter( 'rank_math/frontend/title','custom_meta_title_override');

    Hello,

    Thank you for sharing it with everyone. Appreciate it!

    If you need any other assistance, please feel free to open a new support ticket. We are here to help.

Viewing 3 replies - 1 through 3 (of 3 total)

The ticket ‘Custom Meta Title for Product Categories’ is closed to new replies.