Archived topic
Blog setting "Excerpt word count" doesn't work on other language.
5 replies · Started by Kin on June 1, 2020
Hi all,
I just brought your premium plan a week ago.
Most of the things are good, I am satisfy about that.
However, there is one thing I am so confuse , which is the setting under Customizing > Layout > Blog > Excerpt word count, the default value of "Excerpt word count" should be 20.
There looks nice on your demo page, however, when I already wrote the article with Transitional Chinese version, it seems doesn't count the words correctly. It looks terribly long chinese text display even if I set the "Excerpt word count" to 5-10.
Would you please help or provide some solution can solve this problem?
I am appreciated about this.
Hi there,
this article explains and provides a fix:
http://www.dezzain.com/snippets/how-to-fix-chinese-language-wordpress-excerpts-issue/
Hi, Thank you for your information provided,
I followed your link and fixed the Excerpt word count problem.
However,it seems that another issue existed, the problem is the "read more" button only disappear on chinese language article,the default english article remain normal, please check this
I am look forward to hearing from your.
Thanks a lot.
This is the image showing the problem
https://drive.google.com/file/d/1nGk7iCCMpZfXNI1l5zXF0O1NXW6bOI6k/view?usp=sharing
Try this function:
function dez_filter_chinese_excerpt( $output ) {
global $post;
//check if its chinese character input
$chinese_output = preg_match_all("/\p{Han}+/u", $post->post_content, $matches);
if($chinese_output) {
$output = sprintf( '%1$s <p class="read-more-button-container"><a class="button" href="%2$s">%3$s</a></p>',
mb_substr( $output, 0, 50 ) . '...',
get_permalink(),
__( 'Read more', 'generatepress' )
);
}
return $output;
}
add_filter( 'get_the_excerpt', 'dez_filter_chinese_excerpt' );
Thank you for your help,
The problem has been solved.