Filtering wp_query by dates in meta

Home Forums WPAlchemy Filtering wp_query by dates in meta

Tagged: , ,

This topic contains 1 reply, has 1 voice, and was last updated by  DesignUtensil 1 year, 5 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • #2755


    Okay, this one’s a bit of a toughie.

    The posts on my site are events, from the custom post type “Events”. They list out on the main page in chronological order, dictated by a datepicker in the post meta.

    What I want:

    Events in the past (anything before ‘today’) will not be loaded.

    I’ve been fiddling with the wp_query for ages, just can’t figure it out. I’m using the EXTRACT mode to save out the input date, and use that in the query args to sort by the event date (not the post date, which is irrelevant in this instance). I figure if I could somehow, in the query, compare the event date to today’s date, then I can make it like,

    event_date >= today_date

    Any advice on how to do this? These are my args for the query:

    $args = array(
    'post_type' => 'events',
    'meta_key' => 'event_date',
    'orderby' => 'meta_value',
    'order' => 'asc',
    'posts_per_page' => -1



    • This topic was modified 1 year, 5 months ago by  DesignUtensil.


    Hoping I won’t have to wait a month for a response like the last guy 😀

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.