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.
$popularposts = new WP_Query('showposts=10&meta_key=post_views_count&orderby=meta_value_num&order=DESC&ignore_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.