Как вывести количество слов в блоге WordPress
В functions.php добавить:
1 2 3 4 5 6 7 8 9 10 11 12 |
function post_word_count() { $count = 0; $posts = get_posts( array( 'numberposts' => -1, 'post_type' => array( 'post', 'page' ) )); foreach( $posts as $post ) { $count += str_word_count( strip_tags( get_post_field( 'post_content', $post->ID ))); } $num = number_format_i18n( $count ); echo $num; } |
И там где нужно показать число вставить:
1 |
< ?php post_word_count();?> |
Рассказать: