Archive stats

Discussion in 'Blogging' started by sharkyx, Jul 1, 2007.

  1. #1
    Hey i'm looking for a plugin or like code for display some archive stats. I mean i saw archive stats on a number of bloggs and i found them neat.

    " The blog x has 3131 posts with 21313 comments in 321312 categories."

    link to my archives.
     
    sharkyx, Jul 1, 2007 IP
  2. Etherfast

    Etherfast Peon

    Messages:
    1,192
    Likes Received:
    54
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Well, that's quite simple. All you have to do is extract the variables form the DB then display them ;)

    Try this in your sidebar.php (of course, included in a styled div or already formatted as it only displays what you wanted):
    
    <?php
    $numposts = (int) $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish'");
    $numcomms = (int) $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_approved = '1'");
    $numcats  = (int) $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->categories");
    
    $post_str = sprintf(__ngettext('%1$s <a href="%2$s" title="Posts">post</a>', '%1$s <a href="%2$s" title="Posts">posts</a>', $numposts), number_format($numposts), 'edit.php');
    $comm_str = sprintf(__ngettext('%1$s <a href="%2$s" title="Comments">comment</a>', '%1$s <a href="%2$s" title="Comments">comments</a>', $numcomms), number_format($numcomms), 'edit-comments.php');
    $cat_str  = sprintf(__ngettext('%1$s <a href="%2$s" title="Categories">category</a>', '%1$s <a href="%2$s" title="Categories">categories</a>', $numcats), number_format($numcats), 'categories.php');
    ?>
    <p><?php printf(__('The blog X has %1$s with %2$s, in %3$s.'), $post_str, $comm_str, $cat_str); ?></p>
    
    Code (markup):
    Hope this helps,
     
    Etherfast, Jul 1, 2007 IP
  3. CypherHackz

    CypherHackz Well-Known Member

    Messages:
    447
    Likes Received:
    24
    Best Answers:
    0
    Trophy Points:
    155
    #3
    i have make a plugin to display short site stats that you can use to display on your sidebar. it also will display your latest entry and commentator.

    -cypher.
     
    CypherHackz, Jul 2, 2007 IP