Title: wp_count_posts
Last modified: August 21, 2016

---

# wp_count_posts

 *  [mireillesan](https://wordpress.org/support/users/mireillesan/)
 * (@mireillesan)
 * [12 years, 8 months ago](https://wordpress.org/support/topic/wp_count_posts-1/)
 * I’m trying to display a few statistics on my website through a widget with the
   following code:
 *     ```
       <?php
       $count_posts = wp_count_posts('coupon_type');
       $totalcoupons = $count_posts->publish;
       $taxonomystore = wp_count_terms( 'store' );
       echo 'Total number of coupons: '.$totalcoupons;
       echo '<br />Total number of stores: '.$taxonomystore;
       ?>
       ```
   
 * This works just fine but I was wondering how can I improve my code so it also
   displays: _Total number of coupons today/this week/this month/this year_?
 * Any help is much appreciated.

The topic ‘wp_count_posts’ is closed to new replies.

## Tags

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

 * 0 replies
 * 1 participant
 * Last reply from: [mireillesan](https://wordpress.org/support/users/mireillesan/)
 * Last activity: [12 years, 8 months ago](https://wordpress.org/support/topic/wp_count_posts-1/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
