WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I need to grab a list of current events. The events have a start and end date so I need to be able to select a range as opposed to just getting any list of events that have an end date that is after today's date.

Does anyone have any suggestions as to how to do this? (from what I've read there doesn't seem to be a way to use multiple "meta_key" and "meta_compare" values, but there must be a way some how)

Here's an example of what I'm using in my arguments, but I need to also do this for the start date as well:

'meta_key' => 'end_date_value', 'meta_compare' => '>', 'meta_value' => $todaysDate,
share|improve this question
up vote 2 down vote accepted

You can use your current code to create the query and then in your loop run a check before displaying the events something like

query_posts('meta_key' => 'end_date_value', 'meta_compare' => '>', 'meta_value' => $todaysDate);

 while ( have_posts() ) : the_post();
   $post_custom = get_post_custom($post_id);
   if ($startDate < $post_custom['start_date_value']){
    //your loop here


keep in mind that this is not well coded way to do this ,I would probably create a better sql query or use "posts_where" hook.

but its a start

share|improve this answer

Not quite efficent, but you may do two query.

One that extract the events that have a date greater than the startDate, and the other tha have the end time lower than your end data.

Then, you can do an array_intersect() the two arrays.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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