Title: Post/Comment Count Outside the Loop?
Last modified: August 18, 2016

---

# Post/Comment Count Outside the Loop?

 *  [jdcfsu](https://wordpress.org/support/users/jdcfsu/)
 * (@jdcfsu)
 * [20 years, 3 months ago](https://wordpress.org/support/topic/postcomment-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)

 *  [bobafred](https://wordpress.org/support/users/bobafred/)
 * (@bobafred)
 * [20 years, 3 months ago](https://wordpress.org/support/topic/postcomment-count-outside-the-loop/#post-331747)
 * 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.
 * ex:
    `$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.

## Tags

 * [count](https://wordpress.org/support/topic-tag/count/)
 * [dashboard](https://wordpress.org/support/topic-tag/dashboard/)
 * [loop](https://wordpress.org/support/topic-tag/loop/)
 * [php](https://wordpress.org/support/topic-tag/php/)
 * [tag](https://wordpress.org/support/topic-tag/tag/)

 * 1 reply
 * 2 participants
 * Last reply from: [bobafred](https://wordpress.org/support/users/bobafred/)
 * Last activity: [20 years, 3 months ago](https://wordpress.org/support/topic/postcomment-count-outside-the-loop/#post-331747)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
