I have a calendar plugin that uses custom posts types to create events. There are several custom fields that allow me to create various and seemingly unlimited post queries. The one I'm currently focus on is the field containing the "event start date", titled = evcal_start_date.
What I need to do is display the next upcoming event from today, and this has become a bit of a challenge.
<?php $currentdate = date("m/d/Y",mktime(0,0,0,date("m"),date("d"),date("Y"))); $my_query = new WP_Query( array ('showposts' => 1, 'post_type' => 'ajde_events', 'meta_query'=> array( array( 'key' => 'evcal_start_date', 'meta_compare' => '>', 'value' => $currentdate, 'type' => 'DATE', )), 'meta_key' => 'evcal_start_date', 'orderby' => 'meta_value', 'order' => 'ASC' ) ); while ($my_query->have_posts()) : $my_query->the_post(); $title = get_the_title(); $date = get_post_meta($post->ID, 'evcal_start_date', true); endwhile; ?> <div class="featuredtitle"><?php echo $title; ?><br /> <?php echo $date; ?></div>
I've made sure that the formatting of $currentdate matches that of evcal_start_date. It is stored as "5/25/2012".
I can't guarantee my client will always create posts in order and that is why it's imperative to use the custom field of the event's start date.
I would really appreciate any help. Have a wonderful Memorial Day weekend!