Hello, this should do it:
<?php
function filter_posts($where = '') {
//posts in the last 14 days
$where .= " AND post_date > '" . date('Y-m-d', strtotime('-14 days')) . "'";
return $where;
}
add_filter('posts_where', 'filter_posts');
$args = array(
'posts_per_page' => 5,
'orderby' => 'comment_count',
'order' => 'DESC'
);
$filter_posts_query = new WP_Query($args);
remove_filter('posts_where', 'filter_posts');
//loop for displaying posts
while ($filter_posts_query->have_posts()) : $filter_posts_query->the_post();
the_post_thumbnail(array(50,50), array ('class' => 'alignleft'));
?>
<li><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></li>
<?php endwhile; ?>
(@sh3nka7a)
13 years ago
Hello, im currently using this code to display the most commented on my blog, any way to make it display the most commented articles in just two weeks instead from begining?