get_the_categories
Filters the array of categories to return for a post.
Использование
add_filter( 'get_the_categories', 'wp_kama_get_the_categories_filter', 10, 2 );
/**
* Function for `get_the_categories` filter-hook.
*
* @param WP_Term[] $categories An array of categories to return for the post.
* @param int|false $post_id The post ID.
*
* @return WP_Term[]
*/
function wp_kama_get_the_categories_filter( $categories, $post_id ){
// filter...
return $categories;
}
- $categories(WP_Term[])
- An array of categories to return for the post.
- $post_id(int|false)
- The post ID.
Список изменений
| С версии 3.1.0 | Введена. |
| С версии 4.4.0 | Added the $post_id parameter. |
Где вызывается хук
get_the_categories
wp-includes/category-template.php 98
return apply_filters( 'get_the_categories', $categories, $post_id );