blog statistics (4 posts)

  1. keikenti
    Posted 11 years ago #

    ok, another question.

    I want to make a blog statistics thingie in my sidebar, containing number of entries, pages, categories and comments. I looked through the template tag list but didn't see anything that matches the thing I'm looking for.

  2. keikenti
    Posted 11 years ago #

    <h3><?php _e('Blog Stats'); ?></h3>
    $numposts = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE post_status = 'publish'");
    if (0 < $numposts) $numposts = number_format($numposts);

    $numcomms = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_approved = '1'");
    if (0 < $numcomms) $numcomms = number_format($numcomms);

    $numcats = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->categories");
    if (0 < $numcats) $numcats = number_format($numcats);
    <?php printf(__('There are currently %1$s posts and %3$s comments, contained within %5$s categories.'), $numposts, 'edit.php', $numcomms, 'edit-comments.php', $numcats, 'categories.php'); ?>

    I guess that is the code I was looking for (snagged from wp-admin/index.php)

  3. iddapidda
    Posted 11 years ago #

    maybe the wp-stats plugin is something you're looking for?

  4. andemad
    Posted 11 years ago #

    Hi keikenti,

    I've made some small counter-plugins because I wanted them - counting characters, comments, posts, users to comment and such.

    They're all available from http://linux.linux.dk/projects/

Topic Closed

This topic has been closed to new replies.

About this Topic


No tags yet.