Snippet when sharing pages to social media

  • Resolved Kate

    Hi, when I share a page of my website to Facebook, it seems to use the short description field to produce a snippet, whereas for a google search, a default/automatic snippet comes from the main description field.
    As I am using the short description field to embed an audio clip on each product page, this means that the snippet actually shows a file path. Not a great look.
    How can I change this please? I have not been able to find it in the settings.
    An image is attached, for your information. Many thanks in anticipation of your assistance!

    • This topic was modified 7 months, 1 week ago by Kate.
Viewing 11 replies - 1 through 11 (of 11 total)
  • 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:

    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?


    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:, 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?


    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.


    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.


    Let me check with the dev team and will let you know.

    Looking forward to helping you. Thank you.



    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.


    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 11 replies - 1 through 11 (of 11 total)

The ticket ‘Snippet when sharing pages to social media’ is closed to new replies.