Display Your Most Popular Posts In the Last 30 Days Without a Plugin

Here’s a bit of code that I’ve found to be handy. Sometimes you have a site that is already running so many plugins and you hesitate to add another one on top just to display popular posts. Instead you can use this to change your WordPress loop to show your most popular posts by comment count in the last 30 days:

{code type=php}

    ‘” . date(‘Y-m-d’, strtotime(‘-30 days’)) . “‘”;
    return $where;
    add_filter(‘posts_where’, ‘filter_where’);


    while (have_posts()): the_post(); ?>

  • Source: DeluxeBlogTips.com