I am using this get_posts array to retrieve top 15 popular posts by comments. The problem is that it shows those all those highly commented posts from the day posts were added into blog. So, the list sometimes changes but most of the time remains same.
How can I limit/show posts of the last 7 days?
This would show most commented posts of the last week.
Thanks
Here is my code:
global $post;
$args = array(
'orderby' => 'comment_count',
'order' => 'DESC' ,
'numberposts' => 15);
$popular_posts = get_posts( $args );
foreach( $popular_posts as $post ) :
if (has_post_thumbnail()) { ?>
<li>
<div class="widgetimg">
<a href="<?php the_permalink(); ?>"><?php the_post_thumbnail('widgetimg-thumb'); ?></a>
</div>
</li>
<?php } endforeach; ?>
Here is a function which show the posts of last 7days or you can change it according to your requirement.