Hi Brid,
Thanks a lot for your query and we are so sorry about the trouble this must have caused.
Have you added a product description to the product already?
Once you add that, Rank Math will pick that and set your product’s meta description like that.
Hope that helps and please do not hesitate to let us know if you need our assistance with anything else.
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 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,
Could you please provide code to direct Rankmath to preference the Single Product Description set in the Product SEO setting, not the short description.
Thank you.
Hopefully this new default will be be overridden on a per page basis in the page editor.
Thank you.
Hi Joel,
Thanks for the follow up.
You can make use of the following code to get the product description:
add_action( 'rank_math/frontend/description', function( $description ) {
if(is_product()){
global $product;
$product_details = $product->get_data();
$product_full_description = $product_details['description'];
//$product_short_description = $product_details['short_description'];
return $product_full_description;
}
return $description;
});
I hope this info helps. Thank you.
Thank you so much for your fast response.
However the above code does not seem to have made any difference.
Rankmath is still showing the product short description instead of the default “Single Product Description” set in the Product SEO settings.
Hi Joel,
Thanks for the follow up.
Please create a new ticket & share some temporary admin access to your site on the sensitive data section so that we can check this issue for you.
Thank you.
The above code works for my site but it makes another issue. Now in the product category desc is getting from the 1st product in the list (desc from setting), not form the product category (setting).
please check the link,
https://health2delivery.org/buy-ritalin-online/ (product category)
https://health2delivery.org/ritalin-10mg/ (product)