Codex tools: Log in
Contents |
Retrieve the terms for a post.
There is only one default for this function, called 'fields' and by default is set to 'all'. Other values can be 'names' or 'ids'. There are other defaults that can be overridden in wp_get_object_terms().
<?php $terms = wp_get_post_terms( $post_id, $taxonomy, $args ); ?>
//Returns All Term Items for "my_term"
$term_list = wp_get_post_terms($post->ID, 'my_term', array("fields" => "all"));
print_r($term_list);
//Returns Array of Term Names for "my_term"
$term_list = wp_get_post_terms($post->ID, 'my_term', array("fields" => "names"));
print_r($term_list);
//Returns Array of Term ID's for "my_term"
$term_list = wp_get_post_terms($post->ID, 'my_term', array("fields" => "ids"));
print_r($term_list);
Since: 2.8.0
wp_get_post_terms() is located in wp-includes/post.php.