Skip to content

Instantly share code, notes, and snippets.

@jo-snips
Created January 3, 2013 21:14
Show Gist options
  • Save jo-snips/4447338 to your computer and use it in GitHub Desktop.
Save jo-snips/4447338 to your computer and use it in GitHub Desktop.
The Events Calendar - Get Events by Organizer
<?php
$args = array(
'post_type' => array(TribeEvents::POSTTYPE), // use post_type IN () to avoid old tribe queries
'posts_per_page' => -1,
'order' => 'ASC',
'meta_query' => array(
array(
'key' => '_EventOrganizerID',
'value' => get_the_ID(),
'compare' => 'LIKE'
)
)
);
$events = new WP_Query( $args );
if($events->have_posts()) : while ( $events->have_posts() ) : $events->the_post();
?>
<h5 class="entry-title"><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></h5>
<div class="entry-date">
<span class="start"><?php echo tribe_get_start_date(); ?></span>
<?php if(tribe_is_multiday( get_the_ID() ) || tribe_get_all_day( get_the_ID() ) ) : ?>
<span class="divider"> - </span>
<span class="end"><?php echo tribe_get_end_date(); ?></span>
<?php endif; ?>
</div>
<div class="entry-content">
<?php
if (has_excerpt())
the_excerpt();
else
the_content();
?>
<a href="<?php the_permalink(); ?>" class="read-more">View Details &raquo;</a>
</div>
<?php
endwhile;
endif;
wp_reset_query();
?>
@rumspeed
Copy link

Thank you for the gist. I used it as a starting point for a custom function to return a list of upcoming events for a specific author to display on their member pages. I altered the arguments to fit my needs. Thanks again!

After upgrading The Events Calendar to 3.4.1 (also PRO and Community 3.4), it threw two deprecated function warnings. You can find them in line 23 of your gist.

  • tribe_is_multiday() => tribe_event_is_multiday()
  • tribe_get_all_day() => tribe_event_is_all_day()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment