Created
June 8, 2016 15:45
-
-
Save elimn/38d3fee1aede1fd4b2aac92bd3f70419 to your computer and use it in GitHub Desktop.
MT | TEC | Function to obtain a list of upcoming organizers
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
| <?php | |
| /* | |
| * Returns a list of upcoming organizers, behaves like get_posts() | |
| * | |
| * @return array Containing the WP_Post for each organizer | |
| */ | |
| function tribe_get_upcoming_organizers() { | |
| $organizers = get_posts( | |
| array( | |
| 'post_type' => 'tribe_organizer', | |
| 'posts_per_page' => -1, | |
| ) | |
| ); | |
| $upcoming_organizers = array(); | |
| foreach ( $organizers as $o ) { | |
| $args = array( | |
| 'eventDisplay' => 'list', | |
| 'posts_per_page' => 1, | |
| 'meta_query' => array( | |
| array( | |
| 'key' => '_EventOrganizerID', | |
| 'value' => $o->ID, | |
| ) | |
| ), | |
| ); | |
| // Not the most performant way to do this, but should avoid a lot of edge cases | |
| $has_events = tribe_get_events( $args ); | |
| if ( ! empty( $has_events ) ) $upcoming_organizers[] = $o; | |
| } | |
| return $upcoming_organizers; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment