Advertisements

get_the_terms

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

Advertisements

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

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: