Title: Get stats for specific custom post type?
Last modified: September 1, 2016

---

# Get stats for specific custom post type?

 *  Resolved [b-rad](https://wordpress.org/support/users/b-rad/)
 * (@b-rad)
 * [10 years ago](https://wordpress.org/support/topic/get-stats-for-specific-custom-post-type/)
 * Is there a way I can view the stats for only a specific custom post type?
 * [https://wordpress.org/plugins/jetpack/](https://wordpress.org/plugins/jetpack/)

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

 *  Plugin Author [Jeremy Herve](https://wordpress.org/support/users/jeherve/)
 * (@jeherve)
 * Jetpack Mechanic 🚀
 * [10 years ago](https://wordpress.org/support/topic/get-stats-for-specific-custom-post-type/#post-7616134)
 * The Stats interface doesn’t allow you to sort by post type, but you can use the
   WordPress.com Stats API to build your own reports, and get stats for all posts
   belonging to a specific post type.
 * You can learn more about the API here:
    [http://stats.wordpress.com/csv.php](http://stats.wordpress.com/csv.php)
   [https://phoxis.org/2011/04/24/wordpress-com-stats-api/](https://phoxis.org/2011/04/24/wordpress-com-stats-api/)
 *  Thread Starter [b-rad](https://wordpress.org/support/users/b-rad/)
 * (@b-rad)
 * [10 years ago](https://wordpress.org/support/topic/get-stats-for-specific-custom-post-type/#post-7616135)
 * Hi Jeremy,
 * I visited the links you posted and unless I’m missing it I don’t see a parameter
   that allows me to specify a custom post type. I see a way to request stats for
   a specific post, but not all posts in a custom post type.
 *  Plugin Author [Jeremy Herve](https://wordpress.org/support/users/jeherve/)
 * (@jeherve)
 * Jetpack Mechanic 🚀
 * [10 years ago](https://wordpress.org/support/topic/get-stats-for-specific-custom-post-type/#post-7616137)
 * That’s correct. However, since you’re building your own query, you could get 
   a list of post IDs belonging to a specific post type, and then get starts for
   those post IDs.
 *  Thread Starter [b-rad](https://wordpress.org/support/users/b-rad/)
 * (@b-rad)
 * [10 years ago](https://wordpress.org/support/topic/get-stats-for-specific-custom-post-type/#post-7616138)
 * Dang. Unfortunately that’s not feasible as others are creating content under 
   that post type and having to manually build a list of posts would be unsustainable.
   Looks like I’ll need to find another way to get those stats. 🙁
 *  Plugin Author [Jeremy Herve](https://wordpress.org/support/users/jeherve/)
 * (@jeherve)
 * Jetpack Mechanic 🚀
 * [10 years ago](https://wordpress.org/support/topic/get-stats-for-specific-custom-post-type/#post-7616140)
 * You don’t have to build that list manually though. You could build a custom query
   to return all posts in that post type, like so:
 *     ```
       /**
        * Query Arguments.
        * In this example, I look for Jetpack Portfolio posts.
        * I use the <code>fields</code> parameter to only return post IDs, because we don't need anything else here.
        */
       $args = array(
       	'post_type'      => 'jetpack-portfolio',
       	'fields'         => 'ids',
       	'posts_per_page' => '-1'
       );
   
       $custom_query = new WP_Query( $args );
   
       // $custom_query->posts will then return an array of all the post IDs in that post type.
       var_dump( $custom_query->posts );
       ```
   
 * I should mention, however, that querying for all the posts can be a slow query
   if you have a lot of posts in that post type.
 * I’d consequently recommend the following:
    - Only look at a portion of the posts if that can be done (the last 100, for
      example).
    - Cache the results.
    - Cache the results you get from the WordPress.com Stats API as well.
 *  Thread Starter [b-rad](https://wordpress.org/support/users/b-rad/)
 * (@b-rad)
 * [10 years ago](https://wordpress.org/support/topic/get-stats-for-specific-custom-post-type/#post-7616143)
 * Hmmm, I didn’t think of building a plugin for this, but that would probably work.
   Little more work than I was hoping for, but as a fallback I could see this working.
   Thanks for the suggestion.

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

The topic ‘Get stats for specific custom post type?’ is closed to new replies.

 * ![](https://ps.w.org/jetpack/assets/icon.svg?rev=2819237)
 * [Jetpack - WP Security, Backup, Speed, & Growth](https://wordpress.org/plugins/jetpack/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/jetpack/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/jetpack/)
 * [Active Topics](https://wordpress.org/support/plugin/jetpack/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/jetpack/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/jetpack/reviews/)

 * 6 replies
 * 2 participants
 * Last reply from: [b-rad](https://wordpress.org/support/users/b-rad/)
 * Last activity: [10 years ago](https://wordpress.org/support/topic/get-stats-for-specific-custom-post-type/#post-7616143)
 * Status: resolved