The WPFolks app is out on iPhone and Android. Free, no ads. Download on the App Store Get it on Google Play
Skip to main content
Login Join
Snippet · PHP

Add a Word Count Column to the WordPress Posts List

Shared by Amit Dholiya · October 8, 2026 · @manage_posts_columns,manage_posts_custom_column

5 views
1 upvote
Back to Snippets

Steps

  1. Add the PHP code to your theme’s functions.php.
  2. Save the changes.
  3. Go to WordPress Dashboard → Posts → All Posts.
  4. A new Word Count column will appear.
  5. Each post will show its approximate word count.
/**
 * Add Word Count column to WordPress Posts list
 */
function custom_add_word_count_column( $columns ) {

    $columns['word_count'] = 'Word Count';

    return $columns;
}

add_filter( 'manage_posts_columns', 'custom_add_word_count_column' );


/**
 * Display word count in the custom column
 */
function custom_display_word_count_column( $column, $post_id ) {

    if ( 'word_count' === $column ) {

        $content = get_post_field( 'post_content', $post_id );

        $word_count = str_word_count(
            wp_strip_all_tags( $content )
        );

        echo esc_html( $word_count );
    }
}

add_action(
    'manage_posts_custom_column',
    'custom_display_word_count_column',
    10,
    2
);

Tested on

WordPress 6.8

Reported by the author on October 8, 2026. WPFolks has not verified this.

Not tested against WordPress 7.1.3. It may still work.

Know a different way to do this? Add your approach as a variation so folks can compare them side by side.
Submit a variation

0 comments