Title: [Plugin: WordPress Popular Posts] Exlude Certain Posts?
Last modified: August 19, 2016

---

# [Plugin: WordPress Popular Posts] Exlude Certain Posts?

 *  Resolved [rhythmdoctor](https://wordpress.org/support/users/rhythmdoctor/)
 * (@rhythmdoctor)
 * [15 years, 7 months ago](https://wordpress.org/support/topic/plugin-wordpress-popular-posts-exlude-certain-posts/)
 * Is there any way to exclude certain posts? I have some really old posts that 
   are extremely popular but I would rather not include them in this list. Is that
   possible? Thanks.

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

 *  Thread Starter [rhythmdoctor](https://wordpress.org/support/users/rhythmdoctor/)
 * (@rhythmdoctor)
 * [15 years, 7 months ago](https://wordpress.org/support/topic/plugin-wordpress-popular-posts-exlude-certain-posts/#post-1628536)
 * ??
 *  [Héctor Cabrera](https://wordpress.org/support/users/ikki24/)
 * (@ikki24)
 * [15 years, 7 months ago](https://wordpress.org/support/topic/plugin-wordpress-popular-posts-exlude-certain-posts/#post-1628537)
 * Hi there,
 * Currently, there’s no way to achieve this without hacking WordPress Popular Posts’
   code. If you feel like messing around with it, this is what you need to do:
 * # Open wordpress-popular-posts.php using an editor such as Windows’ Notepad or
   Adobe Dreamweaver, find this line:
 * `$mostpopular = $wpdb->get_results("SELECT $wpdb->posts.ID, $wpdb->posts.post_title
   $fields FROM $wpdb->posts $join WHERE $wpdb->posts.post_status = 'publish' AND
   $wpdb->posts.post_password = '' AND $range $force_pv $nopages $exclude GROUP 
   BY $wpdb->posts.ID ORDER BY $sortby DESC LIMIT " . $instance['limit'] . "");`
 * … and change it to:
 * `$mostpopular = $wpdb->get_results("SELECT $wpdb->posts.ID, $wpdb->posts.post_title
   $fields FROM $wpdb->posts $join WHERE $wpdb->posts.post_status = 'publish' AND
   $wpdb->posts.post_password = '' AND $range $force_pv $nopages $exclude AND $wpdb-
   >posts.ID NOT IN(1,3,17,8) GROUP BY $wpdb->posts.ID ORDER BY $sortby DESC LIMIT".
   $instance['limit'] . "");`
 * Notice the `AND $wpdb->posts.ID NOT IN(1,3,17,8)` part? Replace the numbers with
   the actual IDs of the posts you wish to exclude (comma separated) from the list.
 *  Thread Starter [rhythmdoctor](https://wordpress.org/support/users/rhythmdoctor/)
 * (@rhythmdoctor)
 * [15 years, 7 months ago](https://wordpress.org/support/topic/plugin-wordpress-popular-posts-exlude-certain-posts/#post-1628538)
 * Thank you SOO much. Alternatively, and perhaps a featured request, Id love to
   have this built in along with the ability to show popular posts with a limit 
   as to how far back. IE = I could then do a popular posts this week that only 
   draws from posts published during that week, etc…. Anyways, thank you very much
   for this. Ill try it out.
 *  Thread Starter [rhythmdoctor](https://wordpress.org/support/users/rhythmdoctor/)
 * (@rhythmdoctor)
 * [15 years, 7 months ago](https://wordpress.org/support/topic/plugin-wordpress-popular-posts-exlude-certain-posts/#post-1628539)
 * lkki,
 * Would you be so kind as to show me how to do the same thing (manually) but to
   force it to choose between posts published so many days old? IE, is there a way
   to add a filter that chooses popular posts, only if published within “X” days?
   Thanks again. The solution above worked and is very helpful so thanks for that
 *  [simosmme](https://wordpress.org/support/users/simosmme/)
 * (@simosmme)
 * [15 years, 4 months ago](https://wordpress.org/support/topic/plugin-wordpress-popular-posts-exlude-certain-posts/#post-1628578)
 * i would like that option too please!
 * to add a filter that chooses popular posts, only if published within “X” days?
 * how can we do that?
 * please help!
 *  [lstelie](https://wordpress.org/support/users/lstelie/)
 * (@lstelie)
 * [15 years, 2 months ago](https://wordpress.org/support/topic/plugin-wordpress-popular-posts-exlude-certain-posts/#post-1628584)
 * [@ikki24](https://wordpress.org/support/users/ikki24/)
 * Congrats, your hack to exclude a specific post works great.
 * Luc

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

The topic ‘[Plugin: WordPress Popular Posts] Exlude Certain Posts?’ is closed to
new replies.

 * ![](https://ps.w.org/wordpress-popular-posts/assets/icon-256x256.png?rev=1232659)
 * [WP Popular Posts](https://wordpress.org/plugins/wordpress-popular-posts/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wordpress-popular-posts/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wordpress-popular-posts/)
 * [Active Topics](https://wordpress.org/support/plugin/wordpress-popular-posts/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wordpress-popular-posts/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wordpress-popular-posts/reviews/)

 * 6 replies
 * 4 participants
 * Last reply from: [lstelie](https://wordpress.org/support/users/lstelie/)
 * Last activity: [15 years, 2 months ago](https://wordpress.org/support/topic/plugin-wordpress-popular-posts-exlude-certain-posts/#post-1628584)
 * Status: resolved