In my WordPress site, I use this get_posts code:
get_posts(
array (
'numberposts' => 5,
'orderby'=>'comment_count',
'order'=>'DESC',
'post_type' => array ( 'post' )
)
How do I filter it so that the posts are not older than 10 days? So it should only list posts from the past 10 days.
As of 3.7 you can use date_query https://developer.wordpress.org/reference/classes/wp_query/#date-parameters
So it would look like:
The exemple from the doc should work just fine. get_posts() uses WP_Query() behind the scene to make the actual request. For your case the modified example should look something like this: