Open In App

How to add word count in the WordPress Dashboard ?

Last Updated : 01 Mar, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

WordPress is an open-source Content Management System that is based on PHP and MySql and is used to create a dynamic website. It was developed by Matt Mullenweg and Written in PHP. WordPress is one of the most popular that allows customizing and managing the website from its back-end content management system.

If you are using WordPress for blogging and have more than one author to write for your blog website. To reach the particular writing goal, it is necessary to have the word count stats in your WordPress dashboard. So that you can evaluate the content and reach the required word limit. 

In this article, we are going to see how we can add the word count to our WordPress dashboard. Let us get started on how to add the word count to the WordPress dashboard.

How to add the word count in the WordPress dashboard ?

In this article, we are going to see the two methods of how to add the word count to the WordPress dashboard. First, you can add the word count stats using the WordPress plugin and other is by using the custom code.

After installing and activating the plugin, the word count will be displayed in the “Post” section of the Dashboard for each post.

Now let us see how to add the word count using the WordPress plugin step by step:

Step 1: First login to your WordPress dashboard using the user login id and password.

 

Step 2: After login into your WordPress dashboard, now hover over the “Plugins” section and then click on the “Add New” button to add the plugin.

 

Step 3: Now search for “Word Count Analysis” in the search box and then click on the “Install Now” button to install the plugin on your WordPress website.

 

Step 4: After installing the plugin, click on the “Activate” button to activate the plugin on your WordPress website.

 

Step 5: After activating the plugin, now choose the language, we are choosing the English language and then clicking on the “Count and analyze words” button.

 

Step 6: Now it will start showing the word count in front of the posts.

 

This is how you add the word count stats to your WordPress website using the plugin.

Now let us see how we can add the word count stats using the code.

Adding word count using the custom code: This method is for experts who have some coding knowledge in the PHP programming language. 

You have to add the code to the “functions.php” file on your WordPress website.

The “functions.php” file is found in the theme folder. You can find the “functions.php” file in the path of “wp-content/themes/your-theme/functions.php”

Add the code given below and it will start showing the word count stats in your WordPress dashboard.

PHP




<?php
  
// Display the word count in the custom column
// Add custom column to the Posts list in 
// the dashboard
function word_count_column( $columns ) {
    $columns['word_count'] = 'Word Count';
    return $columns;
}
  
add_filter( 'manage_posts_columns', 'word_count_column' );
  
// Populate the custom column in the Posts list
function word_count_column_content( $column, $post_id ) {
    if ( 'word_count' === $column ) {
        $content = get_post_field( 'post_content', $post_id );
        $word_count = str_word_count( strip_tags( $content ) );
        echo $word_count;
    }
}
  
add_action( 'manage_posts_custom_column'
    'word_count_column_content', 10, 2 );
  
?>


Now it will start showing the word count on your WordPress dashboard.

 

This is how you add the word count using the custom code to your WordPress website.



Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads