I'm working on this plugin which creates 2 custom post types. One for artists and one for events. I use multiple metaboxes to set additional values for the events, such as: start-date, end-date, time and ofcourse you can select the artists for the events. This all works well. But now i am trying to create a list of upcoming events and i need some serious help with creating the query.
I have one meta_key called
_datetime which holds the following data:
( [start_date] => 2010-12-08 [end_date] => 2010-12-08 [time] => 12:31 )
Now i want to query my custom post type to do the following:
Select the events sorted by: start_date / time / the_title
My first guess was to make a custom query, but i am no mysql expert, so if you are, can you please give me some directions?
My second try was to sort the
WP_Query by the meta_value of the start_date key. But i can't seem to use an array within my query. This doesn't work.
$loop = new WP_Query( array( 'post_type' => 'WPSM_event', 'posts_per_page' => -1 , 'order' => 'asc', 'orderby' => 'meta_value', 'meta_key' => '_datetime['start_date']' ) ); $count = 0; while ( $loop->have_posts() ) : $loop->the_post(); $count ++;
I really hope someone can help me out here. I look forward to finish this thing and if it's good enough submit it to the wordpress plugin dir. So please let me know what you think!