WordPress CMS modifications
Making WordPress the ultimate CMS!

Jan/08

26

How to show the total number of posts, categories and tags – maybe in your sidebar

It is easy to get WordPress to show the total number of posts, categories and tags – some people like to show this in their sidebar or footer.

Just paste this code into your sidebar or footer template, and obviously style as wished.

<?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 = wp_count_terms('category');
$numtags = wp_count_terms('post_tag');
?>
<p><?php echo 'There are currently ' . $numposts . ' posts' . ', contained within ' . $numcats . ' categories' . ', using ' . $numtags . ' tags.';?></p>

No tags

No comments yet.

Leave a Reply

<<

>>