Globally added meta description for products not showing

#50426
  • Resolved Tecrocket Space
    Rank Math free

    Hi,

    I have just moved from Yoast to Rank Math, I have customized the product meta descriptions to work globally for all products using only the product title attribute. It shows for all others like categories, brands etc. but it doesnt work with products meta description. What i find on the view source page on chrome is it is automatically pulling the short description for the meta. please find the attached link on sensitive data box.

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

    I have updated the sensitive data as requested. Can you please check further?

    Thank you.

    Alberto
    Rank Math business

    Hello,

    Below is the sequence which Rank Math uses to generate the description:

    1) The Description text added in the Description field
    2) If text is not added in the Description field then the plugin will use excerpt/short description
    3) If the short description field is also empty then the plugin will use the value added in the Settings.

    If you want Rank Math to use the value from step 3 instead of 2, then please add below filter code in your themeā€™s functions.php file:

    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 ) {
    			return RankMath\Helper::replace_vars( $desc, $post );
    		}
    	}
    
    	return $description;
    });

    Hope that helps. Thank you.

    Hi Alberto,

    the code really works, thanks alot!

    Todd
    Rank Math free

    Hello,

    We are super happy that this resolved your issue. If you have any other questions in the future, know that we are here to help you.

    If you don’t mind me asking, could you please leave us a review (if you haven’t already) on https://wordpress.org/support/plugin/seo-by-rank-math/reviews/#new-post about your overall experience with Rank Math? We appreciate your time and patience.

    If you do have another question in the future, please feel free to create a new forum topic, and it will be our pleasure to assist you again.

    Thank you.

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

The ticket ‘Globally added meta description for products not showing’ is closed to new replies.