WordPress.org

Ready to get started?Download WordPress

Forums

Total number of posts? (4 posts)

  1. Dgold
    Member
    Posted 8 years ago #

    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.

  2. Mark (podz)
    Support Maven
    Posted 8 years ago #

    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)

  3. Dgold
    Member
    Posted 8 years ago #

    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!)

  4. Jeff Starr
    Member
    Posted 7 years ago #

    Here is another plugin for this:
    BlogStats PCC

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags