Languages: English • get object terms 日本語 (Add your language)
Retrieves the terms associated with the given object(s) in the supplied taxonomies.
It should be noted that the results from wp_get_object_terms are not cached which will result in a db call everytime this function is called. For performance, functions like get_the_terms() (which the results of has been cached), should be used.
<?php wp_get_object_terms( $object_ids, $taxonomies, $args ); ?>
$args = array('orderby' => 'name', 'order' => 'ASC', 'fields' => 'all');
The following information has to do with the $args parameter and for what can be contained in the string or array of that parameter, if it exists.
NOTE: Arguments are passed in the format used by wp_parse_args(). e.g.
Return a list of all 'product' taxonomy terms that are applied to $post:
$product_terms = wp_get_object_terms( $post->ID, 'product' ); if ( ! empty( $product_terms ) ) { if ( ! is_wp_error( $product_terms ) ) { echo '<ul>'; foreach( $product_terms as $term ) { echo '<li><a href="' . get_term_link( $term->slug, 'product' ) . '">' . esc_html( $term->name ) . '</a></li>'; } echo '</ul>'; } }
Since: 2.3.0
wp_get_object_terms() is located in wp-includes/taxonomy.php
.