Skip to content

Instantly share code, notes, and snippets.

@jasonreposa
Created February 17, 2012 23:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jasonreposa/1856089 to your computer and use it in GitHub Desktop.
Save jasonreposa/1856089 to your computer and use it in GitHub Desktop.
Wordpress word count
function my_head() {
global $post;
if (is_single()) {
$short_post = false;
$words = preg_split('/\s+/', strip_tags($post->post_content), -1, PREG_SPLIT_NO_EMPTY);
if (count($words) < 300) {
$short_post = true;
}
}
}
add_action('wp_head', 'my_head');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment