Skip to content

Instantly share code, notes, and snippets.

@ericlbarnes
Created December 22, 2014 15:03
Show Gist options
  • Save ericlbarnes/a6406ba3359e2232c86d to your computer and use it in GitHub Desktop.
Save ericlbarnes/a6406ba3359e2232c86d to your computer and use it in GitHub Desktop.
Count the total words of all posts for the year
<?php
$words = 0;
$posts = query_posts([
'posts_per_page' => -1,
'year' => '2014',
]);
foreach ($posts as $post) {
$words += str_word_count($post->post_content);
}
echo 'Total Words: '. number_format($words);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment