Post/Comment Count Outside the Loop? (2 posts)

  1. jdcfsu
    Posted 9 years ago #

    I am looking to list the number of posts and comments outside the loop, specifically in a "page." I've got the php-exec plugin installed, now all I need is a tag. Surly there is one because it displays on the dashboard. Anyone know what it is?

  2. bobafred
    Posted 9 years ago #

    You can look at the code for the Admin dashboard by looking at: your_site/wp-admin/index.php in your favorite editor to see how it's done.

    It uses SQL queries to return the counts for posts, comments, and categories. I don't believe there are any tags to return this data, but I think there are plugins to accomplish what you are looking for.

    $numposts = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE post_status = 'publish'");

Topic Closed

This topic has been closed to new replies.

About this Topic