Support » Fixing WordPress » Need help using wp_query and meta_query
5 years, 12 months ago
I’ve a list of events with some custom fields.
Two of these custom fields are “date_start” and “date_end”.
“date_start” is always filled, “date_end” could be empty.
“date_start” and “date_end” values are in the “YYYY-MM-DD” format: this must help sorting and filtering.
I need to get a list of all events that follow these two rules:
(date_start >= today() AND date_end >= NULL) OR (date_end != NULL AND date_end >= today())
I’m not sure yet if I must check for NULL (or “”?) to avoid error messages, but this is not the main issue.
I tried to follow the codex page (http://codex.wordpress.org/Template_Tags/query_posts), but the instruction lost me around the “Multiple Custom Field Handling:” part 🙁
I’ve also tried but haven’t been able to get a custom post type for events to work using just meta fields. Here’s the approach I ended up taking: http://wptheming.com/2010/08/how-to-make-an-events-custom-post-type/
Hope that helps.