When your website means business.

WP Query, WP/CP | Type: PHPWP_query with Events Grouped by Month II

Also untested.

$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()) :
$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>

        <h5><?php echo $eventdate; ?></h5>
        <h4><?php the_title(); ?></h4>
        <?php the_content(); ?>
<?php endwhile; else: ?>
<ul id="events">
<li><?php _e('No Events Scheduled! .'); ?></li>
<?php endif; ?>

Reference Links

We use cookies in order to give you the best possible experience on our website. By continuing to use this site, you agree to our use of cookies.