Support » Plugins » Post/Comment Count Outside the Loop?

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

Viewing 1 replies (of 1 total)
  • 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'");

Viewing 1 replies (of 1 total)
  • The topic ‘Post/Comment Count Outside the Loop?’ is closed to new replies.