Created
August 14, 2019 11:36
-
-
Save inetbiz/ababdd67bdbd674f619aa8cc48966501 to your computer and use it in GitHub Desktop.
WordPress Function: Number of Words in Post Content
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment