Title: Restrict to only specific postypes
Last modified: June 7, 2018

---

# Restrict to only specific postypes

 *  Resolved [poco06](https://wordpress.org/support/users/poco06/)
 * (@poco06)
 * [7 years, 11 months ago](https://wordpress.org/support/topic/restrict-to-only-specific-postypes/)
 * Hello,
 * Thanks for this helpful plugin. I’m wondering if it possible to restrict the 
   count only for a specific postype in order not to overload the other part of 
   the site (and also, the datatable postmeta).
 * Let me know
    Regards Pat

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

 *  Plugin Author [Lester Chan](https://wordpress.org/support/users/gamerz/)
 * (@gamerz)
 * [7 years, 11 months ago](https://wordpress.org/support/topic/restrict-to-only-specific-postypes/#post-10374185)
 * If you use the latest version of the plugin [https://github.com/lesterchan/wp-postviews/archive/master.zip](https://github.com/lesterchan/wp-postviews/archive/master.zip),
 * You can do the following in functions.php
 *     ```
       add_filter( 'postviews_should_count', 'postviews_should_count', 10, 2 );
       function postviews_should_count( $should_count, $id ) {
           $post = get_post ( $id );
           return $post->post_type === 'post';
       }
       ```
   
 *  Thread Starter [poco06](https://wordpress.org/support/users/poco06/)
 * (@poco06)
 * [7 years, 11 months ago](https://wordpress.org/support/topic/restrict-to-only-specific-postypes/#post-10381494)
 * Hi and thanks for your quick answer.
 * I have tried but your plugin continue to record all views in the database.
    I
   would like to record only the views that are related to a specific postype, just
   to ensure to limit database access. Any idea? Regards ¨Pat
 *  Plugin Author [Lester Chan](https://wordpress.org/support/users/gamerz/)
 * (@gamerz)
 * [7 years, 11 months ago](https://wordpress.org/support/topic/restrict-to-only-specific-postypes/#post-10383187)
 * Did you replace ‘post’ with the post_type?
 * DO note that existing posts that already have the views will not be affected.
   Only newer created post will not increment their post, but they will still have
   a initial value of 0 in the views meta.
    -  This reply was modified 7 years, 11 months ago by [Lester Chan](https://wordpress.org/support/users/gamerz/).
 *  Thread Starter [poco06](https://wordpress.org/support/users/poco06/)
 * (@poco06)
 * [7 years, 11 months ago](https://wordpress.org/support/topic/restrict-to-only-specific-postypes/#post-10383276)
 * Hi,
 * Yes I have replaced post with my specific postype I want to follow on views.
   
   I have also deleted all previews meta with ‘views’ key and as soon as I display
   a page, a new meta is created for this page. For info, I’m using the WP Fastest
   Cache cache plugin. Do you think this is something that could have an influence
   on this? Regards Pat
 *  Plugin Author [Lester Chan](https://wordpress.org/support/users/gamerz/)
 * (@gamerz)
 * [7 years, 11 months ago](https://wordpress.org/support/topic/restrict-to-only-specific-postypes/#post-10385285)
 * Does the new meta contains 0 or it keeps increasing? I am not sure on the caching
   part as this plugin was never designed to be used with caching.
 *  Thread Starter [poco06](https://wordpress.org/support/users/poco06/)
 * (@poco06)
 * [7 years, 11 months ago](https://wordpress.org/support/topic/restrict-to-only-specific-postypes/#post-10394050)
 * Hi,
 * Seems this is increasing each time we display a page (including the home page).
   
   I have no record with 0. All records have a number >0 Regards Pat
 *  Plugin Author [Lester Chan](https://wordpress.org/support/users/gamerz/)
 * (@gamerz)
 * [7 years, 11 months ago](https://wordpress.org/support/topic/restrict-to-only-specific-postypes/#post-10394144)
 * The other way I can think of is to change
    `https://github.com/lesterchan/wp-
   postviews/blob/master/wp-postviews.php#L56`
 * From
    `if ( is_single() || is_page() ) {`
 * To
    `if ( is_single() && ! is_page() ) {`

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

The topic ‘Restrict to only specific postypes’ is closed to new replies.

 * ![](https://ps.w.org/wp-postviews/assets/icon.svg?rev=978002)
 * [WP-PostViews](https://wordpress.org/plugins/wp-postviews/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-postviews/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-postviews/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-postviews/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-postviews/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-postviews/reviews/)

 * 7 replies
 * 2 participants
 * Last reply from: [Lester Chan](https://wordpress.org/support/users/gamerz/)
 * Last activity: [7 years, 11 months ago](https://wordpress.org/support/topic/restrict-to-only-specific-postypes/#post-10394144)
 * Status: resolved