Skip to content

Instantly share code, notes, and snippets.

Created December 14, 2017 20:45
Show Gist options
  • Save anonymous/ede4b840712a08d1c12573e066b2e25d to your computer and use it in GitHub Desktop.
Save anonymous/ede4b840712a08d1c12573e066b2e25d to your computer and use it in GitHub Desktop.
<!-- Event Date/Time -->
<p class="current-date">
<?php
echo tribe_get_start_date();
echo ' - ';
echo tribe_get_end_time();
?>
</p>
<?php
global $post;
if( tribe_is_recurring_event($post) ) {?> <!-- check if event is recurring -->
<?php
$parent = $post->post_parent;
if ( $parent ) : ?> <!-- if current page is child/recurring event page -->
<?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){ ?>
<p class="current-date">
<?php
echo tribe_get_start_date($child);
echo ' - ';
echo tribe_get_end_time($child);
?>
</p>
<?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) { ?>
<p class="current-date">
<?php
echo tribe_get_start_date($child);
echo ' - ';
echo tribe_get_end_time($child);
?>
</p>
<?php }?> <!-- end foreach -->
<?php endif; ?>
<?php } ?> <!-- end if is recurring event -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment