get_the_terms
Filters the list of terms attached to the given post.
Использование
add_filter( 'get_the_terms', 'wp_kama_get_the_terms_filter', 10, 3 ); /** * Function for `get_the_terms` filter-hook. * * @param WP_Term[]|WP_Error $terms Array of attached terms, or WP_Error on failure. * @param int $post_id Post ID. * @param string $taxonomy Name of the taxonomy. * * @return WP_Term[]|WP_Error */ function wp_kama_get_the_terms_filter( $terms, $post_id, $taxonomy ){ // filter... return $terms; }
- $terms(WP_Term[]|WP_Error)
- Array of attached terms, or WP_Error on failure.
- $post_id(int)
- Post ID.
- $taxonomy(строка)
- Name of the taxonomy.
Список изменений
С версии 3.1.0 | Введена. |
Где вызывается хук
get_the_terms
wp-includes/category-template.php 1314
$terms = apply_filters( 'get_the_terms', $terms, $post->ID, $taxonomy );
Где используется хук в WordPress
wp-includes/revision.php 878
add_filter( 'get_the_terms', '_wp_preview_terms_filter', 10, 3 );