我使用了wp_trim_words
来获取Wordpress段落中的单词。该段落是中文字母。我想从 wordpress 段落中获取 10 个单词。但它正在展示更多的工作。我想。如果它实际是 10 个单词,那么我想取 30 个字符,所以我为此使用了 substr()
。这也返回一个不同的符号。
我用它来获得 10 个单词
wp_trim_words( get_the_content($postlist->post->ID), 10 )
显示是这样的
$result = substr($myStr, 0, 5);
最佳答案
您需要使用mb_substr
而不是substr
。
mb_substr( get_the_content($postlist->post->ID), 0, 10, "utf-8" );
关于wordpress - 想要修剪wordpress中的中文字母,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51589250/