• Resolved Dmitry

    (@stranger03)


    Hello! I can not remove the limit of 160 characters for the length of the meta-description in posts. Meta-description in posts is formed automatically using variables.
    Used the code fragment in functions.php to remove the restriction:

    add_filter( 'rank_math/frontend/description', function( $description ) {
        return substr( $description, 0, 250 );
    });

    But it does not help increase the length of the meta-description.
    If you try on the contrary to limit, for example, up to 100 characters, it works, but an increase over 160 characters does not work.

Viewing 1 replies (of 1 total)
  • Plugin Author Rank Math

    (@rankmath)

    Hello @stranger03,

    Thank you for contacting the support and sorry for any inconvenience that might have been caused due to that.

    Please use the following filter instead:

    add_filter( 'rank_math/frontend/description', function( $description ) {
    	if ( ! is_singular() ) {
    		return $description;
    	}
    	global $post;
        if ( $post->post_excerpt ) {
    		return $post->post_excerpt;
    	}
    	return substr( $post->post_content, 0, 250 );
    });

    Hope that helps.

Viewing 1 replies (of 1 total)
  • The topic ‘How to remove the restriction on the length of the description?’ is closed to new replies.