Created
December 23, 2014 15:06
-
-
Save stephenharris/160995345c289f7408e1 to your computer and use it in GitHub Desktop.
An edited shortcode event list template, grouping events by date
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Add this to your theme for it to take affect. | |
*/ | |
global $eo_event_loop,$eo_event_loop_args; | |
//Date % Time format for events | |
$date_format = get_option('date_format'); | |
$time_format = get_option('time_format'); | |
//The list ID / classes | |
$id = ( $eo_event_loop_args['id'] ? 'id="'.$eo_event_loop_args['id'].'"' : '' ); | |
$classes = $eo_event_loop_args['class']; | |
$current_date = false; | |
?> | |
<?php if( $eo_event_loop->have_posts() ): ?> | |
<?php while( $eo_event_loop->have_posts() ): $eo_event_loop->the_post(); ?> | |
<?php | |
if( $current_date != eo_get_the_start('Ymd') ){ | |
if( $current_date ){ | |
//End previous group | |
echo '</ul>'; | |
} | |
//Start new group | |
echo '<h3>'.eo_get_the_start('jS F Y').'</h3>'; | |
echo '<ul>'; | |
$current_date = eo_get_the_start('Ymd'); | |
} | |
//Generate HTML classes for this event | |
$eo_event_classes = eo_get_event_classes(); | |
//For non-all-day events, include time format | |
$format = ( eo_is_all_day() ? $date_format : $date_format.' '.$time_format ); | |
?> | |
<li class="<?php echo esc_attr(implode(' ',$eo_event_classes)); ?>" > | |
<a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>" ><?php the_title(); ?></a> <?php echo __('on','eventorganiser') . ' '.eo_get_the_start($format); ?> | |
</li> | |
<?php endwhile; ?> | |
<?php elseif( ! empty($eo_event_loop_args['no_events']) ): ?> | |
<ul id="<?php echo esc_attr($id);?>" class="<?php echo esc_attr($classes);?>" > | |
<li class="eo-no-events" > <?php echo $eo_event_loop_args['no_events']; ?> </li> | |
</ul> | |
<?php endif; ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment