Title: Post Count For Certain Year
Last modified: August 19, 2016

---

# Post Count For Certain Year

 *  Resolved [thisisedie](https://wordpress.org/support/users/thisisedie/)
 * (@thisisedie)
 * [17 years, 4 months ago](https://wordpress.org/support/topic/post-count-for-certain-year/)
 * I want to get the post count for a certain year. I’ve tried doing different things
   with this code
 *     ```
       <?php
       $count_posts = wp_count_posts();
       echo $count_posts->publish;
       ?>
       ```
   
 * but none work. Can anyone tell me how I can do this?

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

 *  [MichaelH](https://wordpress.org/support/users/michaelh/)
 * (@michaelh)
 * [17 years, 4 months ago](https://wordpress.org/support/topic/post-count-for-certain-year/#post-944738)
 * Could use [wpdb](http://codex.wordpress.org/wpdb) on the `wp_posts` table but
   this seems easier:
 *     ```
       <?php
       $count=0;
       $my_query = new WP_Query('year=2008');
       while ($my_query->have_posts()) : $my_query->the_post();
       $count++;
       endwhile;
       echo '2008 post count is ' . $count;
       ?>
       ```
   
 *  Thread Starter [thisisedie](https://wordpress.org/support/users/thisisedie/)
 * (@thisisedie)
 * [17 years, 4 months ago](https://wordpress.org/support/topic/post-count-for-certain-year/#post-944790)
 * Thanks muchly 🙂

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

The topic ‘Post Count For Certain Year’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 2 replies
 * 2 participants
 * Last reply from: [thisisedie](https://wordpress.org/support/users/thisisedie/)
 * Last activity: [17 years, 4 months ago](https://wordpress.org/support/topic/post-count-for-certain-year/#post-944790)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
