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 month ago.

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

    DesignUtensil
    Participant

    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
    );

     

     

    #2757

    DesignUtensil
    Participant

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

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

You must be logged in to reply to this topic.