I am making my first post view counter. I have stored views in post-view
meta and latest date meta post_view_last
. Now I want to show posts from say last 7 days, last 30 days. My query for last 7 days is below but it's not displaying posts. Basic principle-
- Query post last 7 days
post_view_last
Order post based on post views
post-view
$args = array( 'post_type' => 'post', 'posts_per_page' => '3', 'post_status' => 'publish', 'meta_key' => 'post_view',// say 200 'orderby' => 'meta_value_num', 'order' => 'DSC', 'meta_query' => array( 'relation' => 'AND', array( 'key' => 'post_view_last',//2017-04-14 'value' => date('Y-m-d', strtotime('-7 days')), //value of "order-date" custom field 'compare' => '<=', //show post less than or equal to today 'type' => 'CHAR' )));