meta query condition don’t work
Question
I have created a custom post type (Event). I want to show only two posts on the front page and the post should be greater than or equal to today’s date. So I write this meta_query.
$today = date('ymd');
$homePostEvents = new WP_Query(array(
'posts_per_page' => -1,
'post_type' => 'event',
'meta_key' => 'event_date',
'orderby' => 'meta_value_num',
'order' => 'ASC',
'meta_query' => array(
array(
'key' => 'event_date',
'compare' => '>=',
'value' => $today, // Today,
'type' => 'NUMERIC'
)
)
));
So the outcome should be the future date event post but it also bring up the previous date post too.
0
custom-post-types, meta-query, wp-query
3 years
2020-06-01T22:10:26-05:00
2020-06-01T22:10:26-05:00 0 Answers
97 views
0
Leave an answer