wc_get_object_terms()
Helper to get cached object terms and filter by field using wp_list_pluck(). Works as a cached alternative for wp_get_post_terms() and wp_get_object_terms().
Хуков нет.
Возвращает
Массив.
Использование
wc_get_object_terms( $object_id, $taxonomy, $field, $index_key );
- $object_id(int) (обязательный)
- Object ID.
- $taxonomy(строка) (обязательный)
- Taxonomy slug.
- $field(строка)
- Field name.
По умолчанию:null - $index_key(строка)
- Index key name.
По умолчанию:null
Список изменений
| С версии 3.0.0 | Введена. |
Код wc_get_object_terms() wc get object terms WC 10.8.1
function wc_get_object_terms( $object_id, $taxonomy, $field = null, $index_key = null ) {
// Test if terms exists. get_the_terms() return false when it finds no terms.
$terms = get_the_terms( $object_id, $taxonomy );
if ( ! $terms || is_wp_error( $terms ) ) {
return array();
}
return is_null( $field ) ? $terms : wp_list_pluck( $terms, $field, $index_key );
}