Advertisements

wp_get_post_terms

Definition:
function wp_get_post_terms( $post_id = 0, $taxonomy = 'post_tag', $args = array() {}

Retrieve the terms for a post.
There is only one default for this function, called ‘fields’ and by default is set to ‘all’. There are other defaults that can be overridden in wp_get_object_terms().

Parameters

  • int $post_id: Optional. The Post ID
  • string $taxonomy: The taxonomy for which to retrieve terms. Defaults to post_tag.
  • array $args: Optional. Overwrite the defaults

Return values

returns:List of post tags.

Source code

function wp_get_post_terms( $post_id = 0, $taxonomy = 'post_tag', $args = array() ) {

	$post_id = (int) $post_id;



	$defaults = array('fields' => 'all');

	$args = wp_parse_args( $args, $defaults );



	$tags = wp_get_object_terms($post_id, $taxonomy, $args);



	return $tags;

}

3739

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s

%d bloggers like this: