Description excerpt length too short in Japanese

#13748
  • Resolved Sakiwai
    Rank Math free

    Default %excerpt% in Description box show too short length.
    <meta property=”og:description” content=*************

    Yoast default: 150 characters (Japanese)
    RankMath default: only 45 characters or just one sentence.

    It look funny in Google search result page.
    This is critical problem, returning to Yoast.

    Can fix it ?

    • This topic was modified 5 years, 2 months ago by Sakiwai.
Viewing 7 replies - 1 through 7 (of 7 total)
  • Hello,

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

    Thank you.

    Hello,

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

    I have just tested this on my end but I cannot reproduce the issue. The generation of the excerpt works with 160 characters.
    Could you please perform the tests described on this page to help in isolating the culprit: https://rankmath.com/kb/check-plugin-conflicts/

    Looking forward to helping you. Thank you.

    ​​​​​​​

    SEO Titles & Meta >> Posts
    “Single Post Description” was empty as default.

    After I put “%excerpt%” in this box, it worked 160 characters.
    It was confusing because another “Description” setting box exist bellow.

    Now it is better if user can select how many characters to display for description.
    Google search result normally show more than 160 character to 300 Characters.

    So I modified seo-by-rank-math/includes/class-replace-vars.php
    as bellow:

    	private function get_excerpt() {
    		$replacement = null;
    
    		if ( ! empty( $this->args->ID ) ) {
    			if ( '' !== $this->args->post_excerpt ) {
    				$replacement = strip_tags( $this->args->post_excerpt );
    			} elseif ( '' !== $this->args->post_content ) {
    				$replacement = wp_html_excerpt( WordPress::strip_shortcodes( $this->args->post_content ), 500 );
      $replacement = preg_replace('/<!--more-->.+/is', '', $replacement); 
      $replacement = strip_tags($replacement);
      $replacement = str_replace('&nbsp;', '', $replacement);
    define('URL_REG_STR', '(https?|ftp)(:\/\/[-_.!~*\'()a-zA-Z0-9;\/?:\@&=+\$,%#]+)');
    define('URL_REG', '/'.URL_REG_STR.'/');
      $replacement = preg_replace(URL_REG, '', $replacement);	
      $replacement = preg_replace('/  /', '', $replacement); 
      $replacement = wp_html_excerpt( $replacement, 300 );
    			}
    		}
    
    		return $replacement;
    	}

    Yoast SEO, meta description setting box can be left empty.
    Then I put in functions.php:

    function custom_excerpt_length( $length ) {
         return 350;	
    }	
    add_filter( 'excerpt_length', 'custom_excerpt_length', 999 );

    Then,
    og:description and twitter:description is set by get_the_excerpt() 350 characters.
    Google search result shows og:description, might be easier.

    Hello,

    Thank you for the suggestions.

    I have passed this on to our dev team and hopefully they will consider adding this feature in the upcoming versions.

    Looking forward to helping you. Thank you.

    ​​​​​​

    Hello,

    Now it is better if the user can select how many characters to display for description.
    Google search result normally show more than 160 characters to 300 Characters.

    It’s not true. Search engines like Google truncate the description to 155 – 160 characters. You can read more about it here: https://moz.com/learn/seo/meta-description

    Also, to change the meta description please use filter code instead of changing the code in the plugin file so you won’t lose the changes after updating the plugin. You can use below filter code to change the description:

    
    add_filter( 'rank_math/frontend/description', function( $description ) {
    	if ( is_single() ) {
    		$description = get_the_excerpt();
    	}
    
    	return $description;
    });
    
    

    Hope that helps. Thank you.

    I tried your filter code, then found problem.

    Some of my single posts have description already specifically set.
    But your filter code neglect this post description by get_the_excerpt();.
    Any idea ?

    Hello,

    Please use below filter code to show the description if it exists:

    
    add_filter( 'rank_math/frontend/description', function( $description ) {
    	if ( is_single() ) {
    		$rm_desc     = get_post_meta( get_the_ID(), 'rank_math_description', true );
    		$description = $rm_desc ? $rm_desc : get_the_excerpt();
    	}
    
    	return $description;
    });
    

    Hope that helps. Thank 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 7 replies - 1 through 7 (of 7 total)

The ticket ‘Description excerpt length too short in Japanese’ is closed to new replies.