Created
March 21, 2017 15:28
-
-
Save anonymous/0f5c54d6b3483b6a9bad46e80bc5783b to your computer and use it in GitHub Desktop.
The Events Calendar Pro: Recurring events list in single event page.
This file contains hidden or 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
<p>This event is planned 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 } ?> <!-- end if is recurring event --> |
It seems not wo work anymore?
No recurring event would be displayed.
Do you have another solution?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This works great, except I would recommend changing:
'post_type' => 'any'
to:
'post_type' => 'tribe_events'
otherwise you'll pull featured images or any other attached media.