-
-
Save nefeline/7a087e946e4c46bd30e64ae547c6e4d1 to your computer and use it in GitHub Desktop.
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 | |
/** | |
* Custom Single Event Template: Adds a list with all recurring events at the top of each single event. | |
* This template overrides the default single-event.php file | |
* Add this template on [your-theme]/tribe-events/single-event.php | |
*/ | |
?> | |
<p>This event starts on:</p> | |
<p class="current-date"> | |
<?php | |
echo tribe_get_start_date(); | |
echo ' - '; | |
echo tribe_get_end_date(); | |
?> | |
</p> | |
<?php | |
global $post; | |
if( tribe_is_recurring_event($post) ) {?> <!-- check if event is recurring --> | |
<hr> | |
<p>The event is also available on:</p> | |
<ul class="calendar-list"> | |
<?php | |
$parent = $post->post_parent; | |
if ( $parent ) : ?> <!-- if current page is child/recurring event page --> | |
<?php | |
/* get main/parent event */ | |
$parent_title = get_the_title($parent); ?> | |
<a href="<?php echo get_permalink($parent); ?>"> | |
<li> | |
<?php | |
echo $parent_title; | |
echo ': '; | |
echo tribe_get_start_date($parent); | |
?> | |
</li> | |
</a> | |
<?php | |
/* get all recurring events except current */ | |
$args = array( | |
'post_parent' => $parent, | |
'post_type' => 'any', | |
'numberposts' => -1, | |
); | |
$children = get_children( $args ); | |
foreach ($children as $child) { | |
if($post->ID != $child->ID){ ?> | |
<a href="<?php echo get_permalink($child); ?>"> | |
<li> | |
<?php | |
echo get_the_title($child); | |
echo ': '; | |
echo tribe_get_start_date($child); | |
?> | |
</li> | |
</a> | |
<?php } ?> <!-- end if --> | |
<?php } ?> <!-- end foreach --> | |
<?php else : ?> <!-- if current page is parent/main event page --> | |
<?php | |
/* get all recurring events */ | |
$args = array( | |
'post_parent' => $post->ID, | |
'post_type' => 'any', | |
'numberposts' => -1, | |
); | |
$children = get_children( $args ); | |
foreach ($children as $child) { ?> | |
<a href="<?php echo get_permalink($child); ?>"> | |
<li> | |
<?php | |
echo get_the_title($child); | |
echo ': '; | |
echo tribe_get_start_date($child); | |
?> | |
</li> | |
</a> | |
<?php }?> <!-- end foreach --> | |
<?php endif; ?> | |
</ul> | |
<?php } | |
if ( ! defined( 'ABSPATH' ) ) { | |
die( '-1' ); | |
} | |
$events_label_singular = tribe_get_event_label_singular(); | |
$events_label_plural = tribe_get_event_label_plural(); | |
$event_id = get_the_ID(); | |
?> | |
<div id="tribe-events-content" class="tribe-events-single"> | |
<p class="tribe-events-back"> | |
<a href="<?php echo esc_url( tribe_get_events_link() ); ?>"> <?php printf( '« ' . esc_html_x( 'All %s', '%s Events plural label', 'the-events-calendar' ), $events_label_plural ); ?></a> | |
</p> | |
<!-- Notices --> | |
<?php tribe_the_notices() ?> | |
<?php the_title( '<h1 class="tribe-events-single-event-title">', '</h1>' ); ?> | |
<div class="tribe-events-schedule tribe-clearfix"> | |
<?php echo tribe_events_event_schedule_details( $event_id, '<h2>', '</h2>' ); ?> | |
<?php if ( tribe_get_cost() ) : ?> | |
<span class="tribe-events-cost"><?php echo tribe_get_cost( null, true ) ?></span> | |
<?php endif; ?> | |
</div> | |
<!-- Event header --> | |
<div id="tribe-events-header" <?php tribe_events_the_header_attributes() ?>> | |
<!-- Navigation --> | |
<h3 class="tribe-events-visuallyhidden"><?php printf( esc_html__( '%s Navigation', 'the-events-calendar' ), $events_label_singular ); ?></h3> | |
<ul class="tribe-events-sub-nav"> | |
<li class="tribe-events-nav-previous"><?php tribe_the_prev_event_link( '<span>«</span> %title%' ) ?></li> | |
<li class="tribe-events-nav-next"><?php tribe_the_next_event_link( '%title% <span>»</span>' ) ?></li> | |
</ul> | |
<!-- .tribe-events-sub-nav --> | |
</div> | |
<!-- #tribe-events-header --> | |
<?php while ( have_posts() ) : the_post(); ?> | |
<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>> | |
<!-- Event featured image, but exclude link --> | |
<?php echo tribe_event_featured_image( $event_id, 'full', false ); ?> | |
<!-- Event content --> | |
<?php do_action( 'tribe_events_single_event_before_the_content' ) ?> | |
<div class="tribe-events-single-event-description tribe-events-content"> | |
<?php the_content(); ?> | |
</div> | |
<!-- .tribe-events-single-event-description --> | |
<?php do_action( 'tribe_events_single_event_after_the_content' ) ?> | |
<!-- Event meta --> | |
<?php do_action( 'tribe_events_single_event_before_the_meta' ) ?> | |
<?php tribe_get_template_part( 'modules/meta' ); ?> | |
<?php do_action( 'tribe_events_single_event_after_the_meta' ) ?> | |
</div> <!-- #post-x --> | |
<?php if ( get_post_type() == Tribe__Events__Main::POSTTYPE && tribe_get_option( 'showComments', false ) ) comments_template() ?> | |
<?php endwhile; ?> | |
<!-- Event footer --> | |
<div id="tribe-events-footer"> | |
<!-- Navigation --> | |
<h3 class="tribe-events-visuallyhidden"><?php printf( esc_html__( '%s Navigation', 'the-events-calendar' ), $events_label_singular ); ?></h3> | |
<ul class="tribe-events-sub-nav"> | |
<li class="tribe-events-nav-previous"><?php tribe_the_prev_event_link( '<span>«</span> %title%' ) ?></li> | |
<li class="tribe-events-nav-next"><?php tribe_the_next_event_link( '%title% <span>»</span>' ) ?></li> | |
</ul> | |
<!-- .tribe-events-sub-nav --> | |
</div> | |
<!-- #tribe-events-footer --> | |
</div><!-- #tribe-events-content --> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment