Last active
April 17, 2019 21:57
-
-
Save joshfeck/eef917b1338fe9c7af0a2ba93478d65a to your computer and use it in GitHub Desktop.
See lines 16 and 42-46 for an example of how to add the name of the month to the Events Grid View
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 | |
// Options | |
$date_format = get_option( 'date_format' ); | |
$time_format = get_option( 'time_format' ); | |
$temp_month = ''; | |
$reg_button_text = !isset($button_text) ? __('Register Now!', 'event_espresso') : $button_text; | |
$alt_button_text = !isset($alt_button_text) ? __('View Details', 'event_espresso') : $alt_button_text;//For alternate registration pages | |
if ( have_posts() ) : | |
// allow other stuff | |
do_action( 'AHEE__espresso_grid_template_template__before_loop' ); | |
?> | |
<div id="mainwrapper" class="espresso-grid"> | |
<?php | |
// initialize month | |
$new_month = ''; | |
// Start the Loop. | |
while ( have_posts() ) : the_post(); | |
// Include the post TYPE-specific template for the content. | |
global $post; | |
//Create the event link | |
$external_url = $post->EE_Event->external_url(); | |
$button_text = !empty($external_url) ? $alt_button_text : $reg_button_text; | |
$registration_url = !empty($external_url) ? $post->EE_Event->external_url() : $post->EE_Event->get_permalink(); | |
$feature_image_url = $post->EE_Event->feature_image_url(); | |
if(!isset($default_image) || $default_image == '') { | |
$default_image = EE_GRID_TEMPLATE_URL .'images/default.jpg'; | |
} | |
$image = !empty($feature_image_url) ? $feature_image_url : $default_image; | |
$datetimes = EEM_Datetime::instance()->get_datetimes_for_event_ordered_by_start_time( $post->ID, $show_expired, false, 1 ); | |
$datetime = end( $datetimes ); | |
if ($datetime instanceof EE_Datetime) { | |
$start_date = date_i18n( $date_format, strtotime( $datetime->start_date('Y-m-d') ) ); | |
$start_time = date_i18n( $time_format, strtotime( $datetime->start_time('H:i:s') ) ); | |
// add month to markup | |
$month = $datetime->start_date('M'); | |
if ($new_month != $month) { | |
echo '<div style="clear:both;"><h3>' .date_i18n('F', strtotime("first day of " . $month)) . '</h3></div>'; | |
$new_month = $month; | |
} | |
// end add month to markup | |
?> | |
<div id="event-id-<?php echo $post->ID; ?>" class="ee_grid_box_v2 item"> | |
<?php do_action( 'AHEE__espresso_grid_template_template__grid_item_start', $post ); ?> | |
<img src="<?php echo $image; ?>" alt="<?php echo sprintf( esc_attr__( '%s Feature Image', 'event_espresso'), $post->post_title ); ?>" /> | |
<div onclick="" class="darken ee_overlay"> | |
<p class="event-link"><?php echo '<a class="register-link button" id="a_register_link-' . $post->ID .'" href="' . $registration_url . '">' . $button_text . '</a>'; ?></p> | |
<div class="event-title title"><?php echo $post->post_title; ?></div> | |
<p class="start-date"> | |
<span class="event-start-date"><?php echo $start_date; ?></span> | |
| |
<span class="event-start-time"><?php echo $start_time; ?></span> | |
</p> | |
</div> | |
<?php do_action( 'AHEE__espresso_grid_template_template__grid_item_end', $post ); ?> | |
</div> | |
<?php | |
} | |
endwhile; | |
echo '</div>'; | |
// allow moar other stuff | |
do_action( 'AHEE__espresso_grid_template_template__after_loop' ); | |
else : | |
// If no content, include the "No posts found" template. | |
espresso_get_template_part( 'content', 'none' ); | |
endif; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment