WordPress.org

Ready to get started?Download WordPress

Forums

How to display total Post Count and Word Count of blog? (3 posts)

  1. NORTH
    Member
    Posted 8 years ago #

    I've found this "Post Count" and "Word Count" plugins, but they only support old versions (1.2 and 1.5) of WP.

    If anyone knows how to modify these little code snippets to work with WP v2.x, please advise!

    ######################
    POST COUNT for WP v1.5
    ######################

    <?php
    /*
    Plugin Name: Post Count
    Plugin URI: http://mtdewvirus.com/code/wordpress-plugins/
    Description: Outputs the total number of posts.
    Version: 1.1
    Author: Nick Momrik
    Author URI: http://mtdewvirus.com/
    */

    function mdv_post_count() {
    global $wpdb;
    echo $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE post_status = 'publish' AND post_date_gmt < '" . gmdate("Y-m-d H:i:s",time()) . "'");
    }
    ?>

    ##########################
    POST WORD COUNT for WP 1.5
    ##########################

    <?php
    /*
    Plugin Name: Post Word Count
    Plugin URI: http://mtdewvirus.com/code/wordpress-plugins/
    Description: Outputs the total number of words in all posts.
    Version: 1.02
    Author: Nick Momrik
    Author URI: http://mtdewvirus.com/
    */

    function mdv_post_word_count() {
    global $wpdb;
    $now = gmdate("Y-m-d H:i:s",time());
    $words = $wpdb->get_results("SELECT post_content FROM $wpdb->posts WHERE post_status = 'publish' AND post_date < '$now'");
    if ($words) {
    foreach ($words as $word) {
    $post = strip_tags($word->post_content);
    $post = explode(' ', $post);
    $count = count($post);
    $totalcount = $count + $oldcount;
    $oldcount = $totalcount;
    }
    } else {
    $totalcount=0;
    }
    echo number_format($totalcount);
    }
    ?>

  2. barbary
    Member
    Posted 8 years ago #

    BUMP... sorry, any ideas out there on this one? I could use it too.

  3. Jeff Starr
    Member
    Posted 7 years ago #

    Here is a plugin that will display the total number of blog posts, comments, categories, or any combination thereof. May be used inside or outside of the loop, and, yes, it works with WordPress 2.x:
    BlogStats PCC

Topic Closed

This topic has been closed to new replies.

About this Topic