Codex

Function Reference/wp get object terms

Contents

Description

Retrieves the terms associated with the given object(s), in the supplied taxonomies.

The following information has to do the $args parameter and for what can be contained in the string or array of that parameter, if it exists.

The first argument is called, 'orderby' and has the default value of 'name'. The other value that is supported is 'count'.

The second argument is called, 'order' and has the default value of 'ASC'. The only other value that will be acceptable is 'DESC'.

The final argument supported is called, 'fields' and has the default value of 'all'. There are multiple other options that can be used instead. Supported values are as follows: 'all', 'ids', 'names', and finally 'all_with_object_id'.

The fields argument also decides what will be returned. If 'all' or 'all_with_object_id' is choosen or the default kept intact, then all matching terms objects will be returned. If either 'ids' or 'names' is used, then an array of all matching term ids or term names will be returned respectively.

Usage

<?php wp_get_object_terms$object_ids$taxonomies$args ?>

Parameters

$taxonomies
(string|array) (required) The taxonomies to retrieve terms from.
Default: None
$args
(array|string) (optional) Change what is returned
Default: array

Return Values

(array|WP_Error) 
The requested term data or empty array if no terms found. WP_Error if $taxonomy does not exist.

Examples

Notes

Change Log

Since: 2.3.0

Source File

wp_get_object_terms() is located in wp-includes/taxonomy.php.

Related

is_term, get_term, get_term_by, get_term_children, get_terms, wp_get_object_terms

See also index of Function Reference and index of Template Tags.