Credit Cards UK - Loan - Loan - Free Myspace Layouts - Xbox Mod Chip

PDA

View Full Version : Archive stats


sharkyx
Jul 1st 2007, 8:49 am
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 (http://www.zmemusic.com/archives/).

Etherfast
Jul 1st 2007, 4:13 pm
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>


Hope this helps,

CypherHackz
Jul 2nd 2007, 1:10 am
i have make a plugin (http://www.cypherhackz.net/plugins-themes/site-statistics/) to display short site stats that you can use to display on your sidebar. it also will display your latest entry and commentator.

-cypher.