Hi, a post with chinese text can not be limited by the "Limit thumbnail text" option in the Theme Setting. I installed the plugin Chinese Word Count, which gave now the correct word count showing at the bottom of the post entry editor. But still doesn't make the limit thumbnail text work... English version words fine though..
Limit thumbnail text does not work with chinese
(8 posts) (2 voices)-
Posted 11 months ago #
-
Does it show all the text or is the number of words limited wrong? This is a very simple operation where the word count is determined by the spaces.
Posted 11 months ago # -
It shows all the text.. there is no space between the chinese characters. The wordpress built-in word counter didn't work, but after installing the Chinese Word Count plugin, it's now ok. However, I guess the plugin doesn't pass the information to the bigfeature theme? I don't know how to solve this problem.
Posted 11 months ago # -
there is no space between the chinese characters.
Then that's the problem.However, I guess the plugin doesn't pass the information to the bigfeature theme?
It doesn't. I downloaded the Chinese Word Count plugin and that is javascript file, nothing that can be used with the theme implementation that is in php.You can add the thumb text into the excerpt field below the post editor, then that will be used instead of the whole text.
I found this article about Chinese character count in php. This could be implemented in a child theme, since the bf_excerpts function can be overridden. Tell me if you want instruction how to implement it or if you go with the excerpt field method explained above.
Posted 11 months ago # -
Oh Please shed some light as yo how this can be implemented!
Thank you!Posted 11 months ago # -
It is this part of the bf_excerpt function (in library/functions/theme-functions.php) that needs to be recoded:
$words = explode(' ', $content, $excerpt_length + 1); if(count($words) > $excerpt_length) { array_pop($words); $content = implode(' ', $words); $content .= "... "; if ($postType == "normal" || $postType == "feature" || $postType == "portfolio") $readmore = true; if ($readmoreEnabled == "true" && $isThumb) { echo '<p>'. $thumbDateText . $content; ?><a class="more-link" href="<?php the_permalink() ?>"><?php echo $bf_thumb_readmore; ?></a></p> <?php } else echo '<p>' . $thumbDateText . $content . '</p>'; } else { $content = implode(' ', $words); echo '<p>' . $thumbDateText . $content . '</p>'; echo '<div class="clear"></div>'; }You can copy the whole function into a child theme functions.php then it will override the original one. The modified code would be something like this:
$excerpt = mb_strcut($content, 0, $excerpt_length, 'UTF-8'); if(mb_strlen($content, 'UTF-8') > $excerpt_length) { $excerpt .= "... "; if ($postType == "normal" || $postType == "feature" || $postType == "portfolio") $readmore = true; if ($readmoreEnabled == "true" && $isThumb) { echo '<p>'. $thumbDateText . $excerpt; ?><a class="more-link" href="<?php the_permalink() ?>"><?php echo $bf_thumb_readmore; ?></a></p> <?php } else echo '<p>' . $thumbDateText . $excerpt . '</p>'; } else { echo '<p>' . $thumbDateText . $content . '</p>'; echo '<div class="clear"></div>'; }If using a multilingual website, then it must be tested for language and use the orginal code for other than Chinese text.
Posted 10 months ago # -
Hello thanks for the code.
Do you mean copy the whole theme-function.php file to function.php, and replace the first block of code by the second?Posted 10 months ago # -
nope, copy only the bf_excerpt function into a child theme functions.php and modify the code. This is only recommended if you have php knowledge though, since the code above has not been tested.
Posted 10 months ago #
Reply
You must log in to post.