How To Show Total Word Count In WordPress Dashboard

Blog Inbox
2 min readJul 7, 2022


Illustration by Icons 8 from Ouch!

WordPress doesn’t show the number of words your site or blog has combined, but thankfully there is an easy solution for this. With a small piece of PHP, we can easily get the total word count of our site or blog.

Table of Contents

WordPress total word count function

To see the total word count of our WordPress site, we need to add the following code to our functions.php file. This can be done through your hosting’s file editor or through the theme editor in WordPress.

/* Total word count */
add_action( 'dashboard_glance_items', 'bloginbox_wordcount_at_a_glance' );
function bloginbox_wordcount_at_a_glance() {

$count = 0;
$text = " words";
$posts = get_posts( array(
'numberposts' => -1,
'post_type' => 'post'

foreach($posts as $post) {
$count += str_word_count(strip_tags(get_post_field('post_content', $post->ID)));
$num = number_format_i18n($count);
$total = '<li class="word-count"><a href="edit.php">'.$num.$text.'</a></li>';
echo $total;

How to include pages to total word count

If we want to include pages to this we need to change the ‘post_type’ => ‘post’ to ‘post_type’ => ‘any’. By doing this the total word count will include words from pages as well.


In conclusion, adding the total word count to your WordPress dashboard is not hard, but it does require a small amount of code to calculate the total. When added successfully, you can see the total word count of your site or blog in the “At a Glance” widget in your dashboard area.

Disclosure: In compliance with the FTC guidelines, please assume the following links: Any/all of the links on this post are affiliate links from which we receive a small compensation from sales of certain items.

Prices are exactly the same for you if your purchase is through an affiliate link or a non-affiliate link. You will not pay more by clicking through to the link.