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(
            '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. enter image description here

  • In what format are your dates stored?
    – vancoder
    Commented Jun 2, 2020 at 22:16
  • Ymd format..... Commented Jun 2, 2020 at 22:31

1 Answer 1


Can you try changing 'type' => 'NUMERIC' to 'type' => 'DATE' ?

Reference: https://codex.wordpress.org/Class_Reference/WP_Meta_Query

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.