Skip to content

Instantly share code, notes, and snippets.

Created November 25, 2015 15:14
Show Gist options
  • Save anonymous/4dc500f657b858244dff to your computer and use it in GitHub Desktop.
Save anonymous/4dc500f657b858244dff to your computer and use it in GitHub Desktop.
<?php
function add_recurring_event_dates() {
global $wpdb;
// If it's not a recurring event we don't care
if ( ! tribe_is_recurring_event() ) return;
$current_event = get_the_ID();
$parent_event = get_post_field( 'post_parent', $current_event );
$root_event = ( 0 === $parent_event ) ? $current_event : $parent_event;
// It would be nice to use tribe_get_events() or a WP_Query here, but results may
// not be consistent due to recurrence_collapse_sql() logic amongst other things
$instances = $wpdb->get_col( $wpdb->prepare( "
SELECT ID
FROM $wpdb->posts
WHERE post_parent = %d
OR ID = %d
", $root_event, $root_event ) );
if ( empty( $instances ) ) return;
echo 'All dates: ';
foreach ( $instances as $possible_id ) {
if ( Tribe__Events__Main::POSTTYPE !== get_post_type( $possible_id ) )
continue;
if ( 'publish' !== get_post_status( $possible_id ) )
continue;
echo tribe_get_start_date( $possible_id ) . ' ';
}
}
add_action( 'tribe_events_after_the_meta', 'add_recurring_event_dates' );
add_action( 'tribe_events_single_event_after_the_meta', 'add_recurring_event_dates' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment