Change Meta Desc

#214516
  • Resolved Quentin Ruchaud
    Rank Math free

    Hello, I have a new claim,
    On one of my store the short description is displayed by default and I would like to display my long descriptions for the products meta. What is the variable?
    Thank you

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

    Thank you for contacting Rank Math support today.

    Hello,

    Thank you for following up.

    Basically, this is the order we follow to generate meta descriptions for WooCommerce product:
    1. Content from SEO Description field
    If that is missing, then:
    2. WooCommerce Excerpt or Product Short Description
    If that is missing, then:
    3. Template From General Settings in WordPress Dashboard > Rank Math > Titles & Meta > Products
    If that is missing, then:
    4. Auto generated Content from the product page

    So by default, Rank math uses an excerpt of the short product description if no description is added in the description field in Rank math metabox. To use the description set in Global product settings (Rank math > Titles and meta) you can add the following filter to your active theme functions.php file :

    /**
     * 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 ( is_product()) {
     $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 and please do not hesitate to let us know if you need our assistance with anything else.

    Hello, unfortunately I do not have access to the php function of my store.
    That’s why I would like to use the templates you propose in your application (%…%)
    I would like to know which of these functions allows me to display the long description of the product as meta,
    Thanks

    Hello,

    Thank you for keeping in touch with us today.

    Using this filter is the only option we can offer right now to forcibly use the long description.

    If you can’t access your theme’s functions.php file you may use this plugin to insert and configure the filter code we have provided:

    https://wordpress.org/plugins/code-snippets/

    Hope that helps and please do not hesitate to let us know if you need our assistance with anything else.

    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.

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

The ticket ‘Change Meta Desc’ is closed to new replies.