Support » Fixing WordPress » Total number of posts?

  • 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.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Mark (podz)

    (@podz)

    Support Maven

    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

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Total number of posts?’ is closed to new replies.