Definition:
function get_the_terms( $id = 0, $taxonomy ) {}
Retrieve the terms of the taxonomy that are attached to the post.
Parameters
- int $id: Post ID. Is not optional.
- string $taxonomy: Taxonomy name.
Return values
returns:False on failure. Array of term objects on success.
Defined filters
- get_the_terms
apply_filters( 'get_the_terms', $terms, $id, $taxonomy )
Source code
function get_the_terms( $id = 0, $taxonomy ) {
global $post;
$id = (int) $id;
if ( !$id ) {
if ( !$post->ID )
return false;
else
$id = (int) $post->ID;
}
$terms = get_object_term_cache( $id, $taxonomy );
if ( false === $terms ) {
$terms = wp_get_object_terms( $id, $taxonomy );
wp_cache_add($id, $terms, $taxonomy . '_relationships');
}
$terms = apply_filters( 'get_the_terms', $terms, $id, $taxonomy );
if ( empty( $terms ) )
return false;
return $terms;
}
1853

February 12, 2011 


No comments yet... Be the first to leave a reply!