This question already has an answer here:
I've tried doing a WP_Query based on a custom field, which name is 'date' and value is something like '14/01/2015'. I want the query to give results when 'date' is between today and tomorrow.
All I've tried so far is this:
$y=date('d/m/Y',strtotime('yesterday')); $t=date('d/m/Y',strtotime('tomorrow')); $o=date('d/m/Y',strtotime('today')); echo "yesterday: ".$y; echo "today: ".$o; echo "tomorrow: ".$t; $d=new WP_Query( array( 'category__in' => array(4), 'post_type' => 'post', 'posts_per_page' => '-1', 'orderby' => 'meta_value', 'order' => 'DESC', 'meta_query' => array( 'key' => 'data', 'value' => array($y,$t), 'compare' => 'BETWEEN', 'type' => 'DATE', ) ) );
But is giving me posts which 'date' is also 25/01/2015. What am I doing wrong?
Thanks in advice