diff --git a/includes/class-sp-team.php b/includes/class-sp-team.php index 51dfb337..00eefb0c 100644 --- a/includes/class-sp-team.php +++ b/includes/class-sp-team.php @@ -12,6 +12,27 @@ */ class SP_Team extends SP_Custom_Post { + public function next_event() { + $args = array( + 'post_type' => 'sp_event', + 'numberposts' => 1, + 'posts_per_page' => 1, + 'order' => 'ASC', + 'meta_query' => array( + array( + 'key' => 'sp_team', + 'value' => $this->ID + ) + ) + ); + $events = get_posts( $args ); + + if ( count( $events ) ) + return array_shift( $events ); + + return false; + } + /** * Returns formatted data *