Last active
August 23, 2017 18:11
-
-
Save imelgrat/04daad9f76324d5c3d70f41dcaac43d0 to your computer and use it in GitHub Desktop.
Calculate the number of words in a Wordpress post. Full article at: http://imelgrat.me/wordpress/customize-wordpress-post-management-page/
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($post_id) { | |
$content = get_post_field( 'post_content', $post_id ); | |
$word_count = str_word_count( strip_tags( strip_shortcodes($content) ) ); | |
return $word_count; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment