WordPress.org

Support

Support » Plugins and Hacks » [Resolved] [Plugin: WordPress Popular Posts] Exlude Certain Posts?

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

  • rhythmdoctor
    Member

    @rhythmdoctor

    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)
  • rhythmdoctor
    Member

    @rhythmdoctor

    ??

    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.

    rhythmdoctor
    Member

    @rhythmdoctor

    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.

    rhythmdoctor
    Member

    @rhythmdoctor

    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

    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!

    @ikki24

    Congrats, your hack to exclude a specific post works great.

    Luc

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘[Resolved] [Plugin: WordPress Popular Posts] Exlude Certain Posts?’ is closed to new replies.