WpCode.net

Daily Wordpress Code Snippet

How to display the total number of words in your dashboard

| 0 comments

Pin It

This snippet will display in the dashboard the total number of words you use in the blog, will be displayed in the dashboard. Continue reading

function post_word_count() {
    $count = 0;
    $posts = get_posts( array(
        'numberposts' => -1,
        'post_type' => array( 'post', 'page' )
    ));
    foreach( $posts as $post ) {
        $count += str_word_count( strip_tags( get_post_field( 'post_content', $post->ID )));
    }
    $num =  number_format_i18n( $count );
    $text = _n( 'Word', 'Words', $num );
    echo "<tr><td class='first b'>{$num}</td><td class='t'>{$text}</td></tr>";
}
add_action( 'right_now_content_table_end', 'post_word_count');

Leave a Reply

Required fields are marked *.

*