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
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.