Hi Kate,
Thanks for getting in touch with us.
You can choose the description you want to use from the social tab.
Here is a screenshot for reference:
Link to the screenshot: https://i.rankmath.com/Jl5rvR
Hope that helps and please do not hesitate to let us know if you need our assistance with anything else.
Hi Todd, do you mean that I have to do this on every individual page/product?
Hello,
Thank you for contacting Rank Math today.
That would be the way if you wish to have a different description for each page. The othe option would be to use this filter: https://rankmath.com/kb/filters-hooks-api-developer/#change-specific-social-meta, to modify the social share description for your pages.
Hoping this helps you. Thank you.
I just want the snippet to be derived from the description field, rather than the short description field. Is there not a way to change that as a default?
Hello,
I did a simple snippet that you can add at the end of your functions.php file to display the Rank Math SEO Description (if any) instead of the Short Description on each of your posts:
add_filter( "rank_math/opengraph/facebook/og_description", function( $shortDescription ) {
global $post;
$seo_description = get_post_meta( $post->ID, 'rank_math_description', true );
return $seo_description ? $seo_description : $shortDescription;
});
Looking forward to help you.
These seem to now work for some products but not others. Any idea why this would be? Some products are still grabbing the audio filepath from the short description field. Any ideas how to fix?
Thank you for your help.
Can you create a snippet to make it take information from the product description field, instead of the short description field, in the case where the seo description is blank? This is what I need.
Hello,
You can try using the following filter
add_filter( "rank_math/opengraph/facebook/og_description", function(shortDescription) {
global $product;
$seo_description = $product->get_description();
return $seo_description ? $seo_description : $shortDescription;
});
Looking forward to helping you. Thank you.
Hi, are you sure this code is correct? I get an error when I try to add it.
Hello,
Let me check with the dev team and will let you know.
Looking forward to helping you. Thank you.
Hello,
Please add following filter code in your theme’s functions.php to use Product’s main content in the description:
add_filter( 'rank_math/frontend/description', function( $desc ) {
if ( ! function_exists( 'is_product' ) || ! is_product() ) {
return $desc;
}
global $post;
return wp_trim_words( $post->post_content, 160 );
} );
I hope that helps.
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.