How can I add an extra admin column showing the word-count
of a page or post?
If you have any of below questions then you are at right place.
- How to Add Post Word Count Stats to WordPress
- Admin Word Count Column
- Display Total Post Words And Thumbnails
- How to Track Your Word Count in WordPress Posts
- Customizing Admin Columns In WordPress
- Show Word Count of Each Individual Post in WordPress
New Gutenberg Editor give you quick at a glance view of your post. Including:
- Characters
- Blocks
- Word counts
- Heading
- Paragraph and so on.
But what if you want to see Word Count of your previously published posts? It would be great to see Word Count in Admin panel next to Title.
In order to achieve that, you need to modify your theme’s functions.php file and add below code.
Just save it and refresh your Posts admin screen.
// Add WordPress WordCount Column add_filter('manage_posts_columns', 'crunchify_add_wordcount_column'); function crunchify_add_wordcount_column($crunchify_columns) { $crunchify_columns['crunchify_wordcount'] = 'Word Count'; return $crunchify_columns; } // Show WordCount in Admin Panel add_action('manage_posts_custom_column', 'crunchify_show_wordcount'); function crunchify_show_wordcount($name) { global $post; switch ($name) { case 'crunchify_wordcount': $crunchify_wordcount = crunchify_post_wordcount($post->ID); echo $crunchify_wordcount; } } // Get individual post word count function crunchify_post_wordcount($post_id) { $crunchify_post_content = get_post_field( 'post_content', $post_id ); $crunchify_final_wordcount = str_word_count( strip_tags( strip_shortcodes($crunchify_post_content) ) ); return $crunchify_final_wordcount; }
Let me know if you see any issue showing Word Count of your posts in WordPress admin panel.