Dynamic meta description

#76327
  • Resolved Optimizare SEO
    Rank Math free

    Hello.
    On one of my websites, i have enabled BULD EDITING mode in order to create dynamic meta titles and meta descriptions for the products on this page.
    The meta title fields are ok(they are dynamic), but the meta descriptions are not.
    bulk editing
    meta s
    Can you please have a look because I have read all the tutorials and I could not find any solution.

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

    Thank you for contacting Rank Math today.

    I added the following code in your active theme functions’php to resolve the issue.

    /**
     * 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 && is_product()) {
     $desc = RankMath\Helper::get_settings( "titles.pt_{$post->post_type}_description" );
     if ( $desc) {
     return RankMath\Helper::replace_vars( $desc, $post );
     }
     }
    
     return $description;
    });

    Please note that this will only use the description set in Global settings if there is no description set on the product. If you wish to override on all products, you can remove the !desc if check.

    Hope that helps. If you have any further question(s), please let us know. Thank you.

    Wow it worked. Thaks a lot man!!

    Hello,

    We are super happy that this resolved your issue. If you have any other questions in the future, know that we are here to help you.

    If you don’t mind me asking, could you please leave us a review (if you haven’t already) on https://wordpress.org/support/plugin/seo-by-rank-math/reviews/#new-post about your overall experience with Rank Math? We appreciate your time and patience.

    If you do have another question in the future, please feel free to create a new forum topic, and it will be our pleasure to assist you again.

    Thank you.

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

The ticket ‘Dynamic meta description’ is closed to new replies.