Also untested.
<?php $today = date("Y-m-d"); $args = array( 'category_name' => 'events-press', 'orderby' => 'meta_value', 'meta_key' => 'eventsortdate', 'meta_compare' => '>=', 'meta_value' => $today, 'order' => 'ASC' ); $my_query = new WP_Query($args); if ($my_query->have_posts()) : while ($my_query->have_posts()) : $my_query->the_post(); $eventdate = get_post_meta($post->ID, "eventdate", true); $eventsortdate = get_post_meta($post->ID, "eventsortdate", true); ?> <?php if(!isset($currentMonth) || $currentMonth != date("m", strtotime($eventsortdate))){ $currentMonth = date("m", strtotime($eventsortdate)); ?> <li><?php echo date("F", strtotime($eventsortdate)); ?></li> <?php } ?> <ul> <li> <h5><?php echo $eventdate; ?></h5> <h4><?php the_title(); ?></h4> <?php the_content(); ?> </li> </ul> <?php endwhile; else: ?> <ul id="events"> <li><?php _e('No Events Scheduled! .'); ?></li> </ul> <?php endif; ?>
Reference Links
https://stackoverflow.com/questions/3586384/wordpress-events-grouped-by-month