The article page meta description can call the first 150 characters of the artic

#138192
  • Resolved wanshuo
    free

    hello,The article page meta description can call the first 150 characters of the article as the default description

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

    Thank you for contacting Rank Math, and sorry for any inconvenience caused.

    Yes, Rank Math will set the first 160 characters as the default meta description if you do not explicitly set one.

    I hope this helps.

    Hello, I have set the description before, but I feel that the setting is not good, so I want to batch modify the first 160 characters of the article, how to set it

    I am calling %seo_description%, but the previously set %seo_description% is not good, so I want to change it to the first 150 characters of the article

    Hello,

    Thank you for contacting Rank Math.

    You can create your own custom variable and use it on your site like the code below. The code below will limit your content in the post to 150 characters.

    You can use the code below by putting this %limit_description% variable on your snippet.

    You need to add this code to your functions.php in your theme files.

    code – https://pastebin.com/d3tTGLst

    Please see the screenshot for the sample output of the code.

    If you need further assistance, please don’t hesitate to contact us.

    Thank you.

    Hello, I added the code in the functions.php of the current theme, and also added %limit_description% in the rank math, but it doesn’t seem to work. Is there something wrong with the setting?https://i1.guantt.com/2021/01/21/54b065bf3db7c.png

    Hello,

    Thank you for following up.

    You would need to put the %limit_description% in the Single Post Description for the limit to work.

    Limit Description

    I hope that helps. Thank you, and please don’t hesitate to contact us if you need further assistance.

    Hello, is there any way to call the first 150 characters of the article content as the default description on all article pages by default!

    Hello,

    Thank you for following up.

    By default, the %excerpt% variable will call the first 160 characters of your article as description. Since you only want 150 characters, we recommend this filter and using the %limit_description% custom variable.

    Please follow this screencast for step-by-step instructions:
    https://i.rankmath.com/4etYLA

    I hope that helps. Thank you, and looking forward to your update.

    Hello, this did not solve the problem, I want to solve it by disabling the description tag of the article page separately. How can I individually disable the description tag on the article page. Then I will automatically generate the description tag of the article page through the code to achieve the result I want. The problem now is how to individually disable the description tag of the article page so that it is no longer displayed on the article page, and I can solve the rest. Thanks a lot!

    Hello,

    If you had already defined meta description for your pages you will need to use the following filter to override al set meta and use the global settings for the description:

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

    Hope this helps you.

    Hello, this code successfully filtered out the description tag on my homepage, but what I need is to filter out the description tags on all article pages. How do I change this code? Thanks a lot!

    Hello,

    For that you will need to add a condition to check if the page is a post as follows:

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

    Hope this helps

    Hello, I added your code, but the description tag is still displayed on the homepage and articles of my website. Can you help me see if there is a problem with the code? Thank you

    Hello,

    We can look into your settings and code from our end. Please edit the first post on this ticket and include your WordPress & FTP logins in the designated Sensitive Data section.
    Sensitive Data Section

    It is completely secure and only our support staff has access to that section. If you want, you can use the below plugin to generate a temporary login URL to your website and share that with us instead:

    https://wordpress.org/plugins/temporary-login-without-password/

    You can use the above plugin in conjunction with the WP Security Audit Log to monitor what changes our staff might make on your website (if any):

    https://wordpress.org/plugins/wp-security-audit-log/

    We really look forward to helping you.

    Hello,

    I have updated the sensitive data as requested. Can you please check further?

    Thank you.

Viewing 15 replies - 1 through 15 (of 20 total)

You must be logged in to reply to this ticket.