Global Titles and Descriptions for Product Categories and Product Sub categories

#694382
  • Resolved Kosh Mart
    Rank Math free

    Hi,

    I’m trying to give global Titles and Descriptions for Product Categories and Product Sub-categories.

    However there doesn’t seem to be anyway of doing it, there’s just one option “Product Categories” (screenshot attached) and it applies the same global title and description template to all the Product Categories. The other option is to so it at the individual product category level, which defeats the whole purpose of this plugin.

    Product Categories

    I’m not sure if there a better way of doing this, or what this is the limitations of the plugin.

    Thanks

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

    We apologize for the inconvenience you’re experiencing with setting global titles and descriptions for product categories and subcategories. It seems that you are trying to set global titles and descriptions for product categories and subcategories using Rank Math.

    The screenshot you’ve provided shows the “Product Categories” option, which applies the same global title and description template to all product categories. However, it seems that you are looking for a way to set different titles and descriptions for individual product subcategories.

    To achieve this, you can set up individual titles and descriptions for each product category and subcategory by navigating to WordPress Dashboard > Rank Math > Titles & Meta > Product Categories. From there, you can set up individual titles and descriptions for each category and subcategory.

    If you have any further questions or need assistance with this, please feel free to ask.

    Thank you for bringing this to our attention.

    Sources:
    Rank Math ‘Titles and Meta’ Options and Settings

    Hello,

    Thank you for your patience.

    Yes, the product categories in the Titles & Meta option affect all the categories including the parent and child.

    However, you may use and customize these filters to modify the child categories meta title and description:
    https://rankmath.com/kb/filters-hooks-api-developer/#change-the-title
    https://rankmath.com/kb/filters-hooks-api-developer/#change-meta-description

    Hope that helps

    Please give me an example of how to use this?

    /**
    * Allow changing the meta description sentence from within the theme.
    *
    * @param string $description The description sentence.
    */
    add_filter( ‘rank_math/frontend/description’, function( $description ) {
    return $description;
    });

    Hello,

    This filter hook allows you to modify the meta description sentence that Rank Math generates for your pages. The filter hook takes one parameter, $description, which is the original meta description sentence. You can return a modified version of the $description from the filter function.

    For example, if you want to change the description of any product category (child or parent), you can use the following code:

    add_filter( 'rank_math/frontend/description', function( $description ) {
      // Check if the current page is a product category archive page
      if ( is_product_category() ) {
        // Get the product category object
        $product_category = get_queried_object();
    
        // Compare the product category slug or name with your desired sub-category
        if ( $product_category->slug == 'clothing' || $product_category->name == 'Clothing' ) {
          // Return a different description
          return 'This is a special sub-category';
        }
      }
    
      // Return the original description for other cases
      return $description;
    });

    This code will change the SEO description of any product category. You can change the description to anything you want, or use other logic to modify the description.

    You can learn more about the rank_math/frontend/description filter hook and other Rank Math filter hooks from here.

    I hope this helps you understand how to use the filter hook. If you have any further questions or need more assistance, please let us know. We’re always here to help.

    Thank you for choosing Rank Math. Have a great day! 😊

    Hello,

    Since we did not hear back from you for 15 days, we are assuming that you found the solution. We are closing this support ticket.

    If you still need assistance or any other help, please feel free to open a new support ticket, and we will be more than happy to assist.

    Thank you.

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

The ticket ‘Global Titles and Descriptions for Product Categories and Product Sub categories’ is closed to new replies.