Most popular post for last 7 days
I need to change the most popular post widgets with date restrictions.
For an example, how should I get most popular posts(post_views_count) of last 7 days.
original query,
$popularposts = new WP_Query('showposts=10meta_key=post_views_countorderby=meta_value_numorder=DESCignore_sticky_posts=1')
then I changed that to,
$args = array(
'date_query' = array( array( 'after' = '-7 days' ) ),
'showposts' = 10,
'ignore_sticky_posts' = 1,
'meta_key' = 'post_views_count',
'orderby' = 'meta_value_num',
'order' = 'DESC'
);
$the_query = new WP_Query( $args );
However it doesn't give any results. How should I achieve this?
Thanks in advance.
Topic popular-posts wp-query Wordpress
Category Web