When your website means business.

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

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

Menu
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.
Accept
Cookies Notice