From 3315713d4cd9da911791026d3f18a60db200f220 Mon Sep 17 00:00:00 2001 From: Brian Miyaji Date: Wed, 7 May 2014 17:37:08 +1000 Subject: [PATCH] Add next event function to team --- includes/class-sp-team.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) 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 *