Add api functions

This commit is contained in:
Brian Miyaji
2016-03-02 23:08:48 +11:00
parent 2e543cf385
commit 6bf57e27b9

View File

@@ -34,6 +34,18 @@ function sp_get_posts( $post_type = 'post', $args = array() ) {
return get_posts( $args ); return get_posts( $args );
} }
function sp_get_leagues( $post = 0, $ids = true ) {
$terms = get_the_terms( $post, 'sp_league' );
if ( $terms && $ids ) $terms = wp_list_pluck( $terms, 'term_id' );
return $terms;
}
function sp_get_seasons( $post = 0, $ids = true ) {
$terms = get_the_terms( $post, 'sp_season' );
if ( $terms && $ids ) $terms = wp_list_pluck( $terms, 'term_id' );
return $terms;
}
/* /*
* Event functions * Event functions
*/ */
@@ -181,6 +193,12 @@ function sp_get_logo( $post = 0, $size = 'icon', $attr = array() ) {
return get_the_post_thumbnail( $post, 'sportspress-fit-' . $size, $attr ); return get_the_post_thumbnail( $post, 'sportspress-fit-' . $size, $attr );
} }
function sp_get_logo_url( $post = 0, $size = 'icon' ) {
$thumbnail_id = get_post_thumbnail_id( $post );
$src = wp_get_attachment_image_src( $thumbnail_id, $size, false );
return $src[0];
}
function sp_get_abbreviation( $post = 0 ) { function sp_get_abbreviation( $post = 0 ) {
return get_post_meta ( $post, 'sp_abbreviation', true ); return get_post_meta ( $post, 'sp_abbreviation', true );
} }