Meta Description Source for Products

#332405
  • Resolved Rich B.
    Rank Math free

    Hello,

    I’m using WooCommerce and I noticed that my product meta descriptions are being pulled from the short description instead of the long description – which is resulting in many duplicate product meta descriptions.

    I’d rather for the meta description for products to be pulled from my longer descriptions (which are all unique i.e. the text the appears at the bottom of a WooCommerce product page under ‘Description’. This would solve the problem that I’m having and save me a lot of time from having to manually go in a set a unique meta description for each product.

    So is there some way to change where your plugin is pulling my product meta description data?

Viewing 1 replies (of 1 total)
  • Hello,

    Thank you for contacting Rank Math and bringing your concern to our attention. I’m sorry for any inconvenience this issue may have caused you.

    This is the order we follow to generate meta descriptions for WooCommerce products:

    1. Content from the individual SEO Description field
    If that is missing, then:
    2. WooCommerce Excerpt or Product Short Description
    If that is missing, then:
    3. Template From General Settings in WordPress Dashboard > Rank Math > Titles & Meta > Products
    If that is missing, then:
    4. Auto generated Content from the product page (long description)

    To summarize, the short description you have set will be prioritized if you’re using the %excerpt% variable for your description.

    If you wanted to force the usage of the single product description, you may need to use this filter:

    /**
     * Use the Description from Global Setting, if the description is missing in the Post metabox
     */
    add_action( 'rank_math/frontend/description', function( $description ) {
     global $post;
     $desc = RankMath\Post::get_meta( 'description', $post->ID );
    
     if ( is_product()) {
     $desc = RankMath\Helper::get_settings( "titles.pt_{$post->post_type}_description" );
     if ( $desc ) {
     return RankMath\Helper::replace_vars( $desc, $post );
     }
     }
    
     return $description;
    });

    And here’s a link on how to apply a filter on your site:
    https://rankmath.com/kb/filters-hooks-api-developer/#how-to-add-code-snippets-to-rank-math-php

    Please note that the filter may not be visible while editing the products as it only works when your products load in a browser. You can check the published/saved product meta description via the page’s source code.

    I hope that helps.

    Thank you.

    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 1 replies (of 1 total)

The ticket ‘Meta Description Source for Products’ is closed to new replies.