Depending on what you’re trying to achieve you can just perform any WP_Query you like, including date query with orderby “post_views” parameter.
When you do so, you’ll have a new “total_views” data returned along other query data, like posts, found_posts etc. and each post object extended with post_views data (a views number of this specific post).
Example:
$args = array(
'orderby' => 'post_views',
'order' => 'ASC',
'date_query' => array(
array(
'year' => 2016,
'month' => 12,
'day' => 12,
),
),
);
$query = new WP_Query( $args );
– this would result in posts published in 12th december 2016 along their views data and total views data for all posts published in that period
Additionally you can query any posts to get their views data from any period usign the views_query – a PVC extension to native WP_Query
Example:
$args = array(
'orderby' => 'post_views',
'order' => 'ASC',
'views_query' => array(
'year' => 2016,
'month' => 12,
'day' => 12,
)
);
$query = new WP_Query( $args );
– this would result in posts that were viewed on 12th december 2016 along their views data and total views data in that period
You can of course make any WP_Query combination you like.
$args = array(
'orderby' => 'post_views',
'order' => 'ASC',
'views_query' => array(
'year' => 2016,
'month' => 12,
),
'date_query' => array(
array(
'year' => 2016,
'month' => 12,
'day' => 12,
),
)
);
$query = new WP_Query( $args );
– this would result in posts published on 12th december 2016 and their views data for december 2016