How could I 'echo' display the total number of posts in all my categories?
I have a blog with songs in each post, and I want to make the title of the blog 79 Songs. Where the number changes each time I post a new song.
How could I 'echo' display the total number of posts in all my categories?
I have a blog with songs in each post, and I want to make the title of the blog 79 Songs. Where the number changes each time I post a new song.
This is (I think) the function:
// Get Total Posts
function get_totalposts() {
global $wpdb;
$totalposts = $wpdb->get_var("SELECT COUNT(ID) FROM $wpdb->posts WHERE post_status = 'publish'");
return $totalposts;
}
Then:
<?=get_totalposts()?>
or
<?php echo $get_totalposts; ?>
It's the last bit I'm not sure of...
(Code at the top from a plugin by GamerZ)
Thanks Podz.
I ended up using this little plugin called MsgCount, it works easy:
http://andersdrengen.dk/projects/msgcount/
As of today my blog's title is "125 Songs" (and the number will update itself!)
Here is another plugin for this:
BlogStats PCC
This topic has been closed to new replies.