wp_get_object_terms
Filters the terms for a given object or objects.
The $taxonomies parameter passed to this filter is formatted as a SQL fragment. The get_object_terms filter is recommended as an alternative.
Usage
add_filter( 'wp_get_object_terms', 'wp_kama_get_object_terms_filter', 10, 4 ); /** * Function for `wp_get_object_terms` filter-hook. * * @param WP_Term[]|int[]|string[]|string $terms Array of terms or a count thereof as a numeric string. * @param string $object_ids Comma separated list of object IDs for which terms were retrieved. * @param string $taxonomies SQL fragment of taxonomy names from which terms were retrieved. * @param array $args Array of arguments for retrieving terms for the given object(s). See wp_get_object_terms() for details. * * @return WP_Term[]|int[]|string[]|string */ function wp_kama_get_object_terms_filter( $terms, $object_ids, $taxonomies, $args ){ // filter... return $terms; }
- $terms(WP_Term[]|int[]|string[]|string)
- Array of terms or a count thereof as a numeric string.
- $object_ids(string)
- Comma separated list of object IDs for which terms were retrieved.
- $taxonomies(string)
- SQL fragment of taxonomy names from which terms were retrieved.
- $args(array)
- Array of arguments for retrieving terms for the given object(s). See wp_get_object_terms() for details.
Changelog
Since 2.8.0 | Introduced. |
Where the hook is called
wp-includes/taxonomy.php 2357
return apply_filters( 'wp_get_object_terms', $terms, $object_ids, $taxonomies, $args );
Where the hook is used in WordPress
wp-includes/default-filters.php 561
add_filter( 'wp_get_object_terms', '_post_format_wp_get_object_terms' );