Set global meta description as default

#75435
  • Resolved Ahmed Sa’eed
    Rank Math free

    Hi,
    i have set global meta description for product pages and i want to give it priority instead of adding it on every page just like meta title instead of short description

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

    Thank you for contacting Rank Math today.

    Please use add the following code in your active theme functions.php

    /**
     * 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;
    });

    Looking forward to helping you. Thank you.

    ​​​​​​

    thank you also the code to add meta focus key words please i need it for search engines

    Alberto
    Rank Math business

    Hello,

    You can use this code:

    /**
     * Add <meta name="keywords" content="focus keywords">.
     */
    add_filter( 'rank_math/frontend/show_keywords', '__return_true');

    Looking forward to help you.

    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 ‘Set global meta description as default’ is closed to new replies.