I'm planning a site for a client who wants users to be able to filter upcoming events by the following criteria:
Type i.e. Comedy, Theatre, Music etc.
Date Daily or Weekend
Duration Daily or Half day
I want to delve into Custom posts more, so will set up a Custom Post Type for 'Events' (non-hierarchical) and when creating a new post I'll add Custom Fields for Type, Date and Duration.
The question I have is how would I use query_posts() to:
- List the events so that the soonest (i.e. next event to occur) appears first and later events last?
- Filter by multiple meta values (Type, Date and Duration)?
I presume I need to create a series of options in my form's dropdown lists based on the custom field values right?
I've created a list of Events for a client before, but with no filtering possibilities. I used this query_posts() code to get the custom posts and order things:
// List the events by custom field 'Date':
$todaysDate = date('Y/m/d'); // set todays date to check against custom field
// query posts
query_posts('post_type=Event&meta_key=Date&meta_compare=>=&meta_value=' . $todaysDate . '&orderby=meta_value&order=ASC');
However, I can't see how I might change this code to filter by multiple custom fields...any ideas?
Thanks