Title: wp_count_posts
Last modified: August 19, 2016

---

# wp_count_posts

 *  [thetvstop](https://wordpress.org/support/users/thetvstop/)
 * (@thetvstop)
 * [15 years, 8 months ago](https://wordpress.org/support/topic/wp_count_posts/)
 * How do I use wp_count_posts outside of the loop?

Viewing 3 replies - 1 through 3 (of 3 total)

 *  [Michael](https://wordpress.org/support/users/alchymyth/)
 * (@alchymyth)
 * [15 years, 8 months ago](https://wordpress.org/support/topic/wp_count_posts/#post-1618541)
 * wp_count_posts() does not seem to be loop dependant:
    if the docu does not answer
   your question, [http://codex.wordpress.org/Function_Reference/wp_count_posts](http://codex.wordpress.org/Function_Reference/wp_count_posts)
 * you may need to describe in more detail where you want to use this.
 * (btw: the examples in the docu assign the results to variables; if you want to
   output the results, you would need to use the `echo` command.)
 *  Thread Starter [thetvstop](https://wordpress.org/support/users/thetvstop/)
 * (@thetvstop)
 * [15 years, 8 months ago](https://wordpress.org/support/topic/wp_count_posts/#post-1618602)
 * [http://www.thetvstop.com/watch/](http://www.thetvstop.com/watch/) if you look
   at the TOP TV SHOWS, section on top you will see how I am trying to display post
   counts.
 * For some reason the default <?php count_posts(); ?> works to count the total 
   number of posts.
 * However, the <?php count_posts(‘pages’); ?> function does not work. Any clues?
 *  [Michael](https://wordpress.org/support/users/alchymyth/)
 * (@alchymyth)
 * [15 years, 8 months ago](https://wordpress.org/support/topic/wp_count_posts/#post-1618604)
 * > However, the <?php count_posts(‘pages’); ?> function does not work.
 * maybe because it does not exist?
    have you read the docu?
 * if you want to show the number of published pages, try:
 *     ```
       <?php
       $count_pages = wp_count_posts('page');
       echo $count_pages->publish;
       ?>
       ```
   

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘wp_count_posts’ is closed to new replies.

## Tags

 * [wp_count_posts](https://wordpress.org/support/topic-tag/wp_count_posts/)

 * 3 replies
 * 2 participants
 * Last reply from: [Michael](https://wordpress.org/support/users/alchymyth/)
 * Last activity: [15 years, 8 months ago](https://wordpress.org/support/topic/wp_count_posts/#post-1618604)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
