WordPress并没有内置同时统计中文和英文单词字数的函数,网上能找到的代码,或是仅统计英文单词,不能统计中文,或者可以统计中文,但英文按字母而非单词统计。虽然我们不是英文站,但有时文章中会有些英文单词,这样统计就不准确了。 function uctheme_word_count() { $post_content = get_post_field( 'post_content', get_the_ID() ); $striped_tags = strip_tags( $post_content ); // 统计中文 $zh_words = preg_match_all( '/[\x{4e00}-\x{9fa5}]/u…
阅读全文 >>