Product Meta Description not showing globally set description

#72281
  • Resolved Indilotus Team
    Rank Math free

    Hello, Thank You for this amazing plugin

    While setting up my woocommerce product meta description I found that Rankmath is not taking a globally set product meta description like Yoast SEO instead it is taking products short description as meta description. which is not good for my products as in their short description I write only points and when Rankmath takes it as meta description it not look good in reading please check attached screenshot. Please make Product meta description first from globally set settings.

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

    Thank you for contacting Rank Math today.

    The product short description always takes a higher priority when generating a product meta description than the global settings that have been set of the Rank Math > Titles & Meta page.

    To use the global settings, please add the following filter in your them functions.php

    /**
     * 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 ( ! $desc ) {
     $desc = RankMath\Helper::get_settings( "titles.pt_{$post->post_type}_description" );
     if ( $desc && is_singular('product')) {
     return RankMath\Helper::replace_vars( $desc, $post );
     }
     }
    
     return $description;
    });
    

    Plese note this will only use the global description setting if the description is missing on the products. To override this you can remove the if (!$desc) option

    Hope that helps. If you have any further question(s), please let us know. Thank you.

    nothing is changing with your given code in my case always write product short description but I don’t want to use it for product meta description, I want to use Globbaly set values as the description

    Alberto
    Rank Math business

    Hello,

    Then you should try the modification my colleague suggested:

    /**
     * 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 );
    
     $desc = RankMath\Helper::get_settings( "titles.pt_{$post->post_type}_description" );
     if ( $desc && is_singular('product')) {
     return RankMath\Helper::replace_vars( $desc, $post );
     }
    
     return $description;
    });

    Looking forward to help 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 3 replies - 1 through 3 (of 3 total)

The ticket ‘Product Meta Description not showing globally set description’ is closed to new replies.