post_link_category
Filters the category that gets used in the %category% permalink token.
Использование
add_filter( 'post_link_category', 'wp_kama_post_link_category_filter', 10, 3 ); /** * Function for `post_link_category` filter-hook. * * @param WP_Term $cat The category to use in the permalink. * @param array $cats Array of all categories (WP_Term objects) associated with the post. * @param WP_Post $post The post in question. * * @return WP_Term */ function wp_kama_post_link_category_filter( $cat, $cats, $post ){ // filter... return $cat; }
- $cat(WP_Term)
- The category to use in the permalink.
- $cats(массив)
- Array of all categories (WP_Term objects) associated with the post.
- $post(WP_Post)
- The post in question.
Список изменений
С версии 3.5.0 | Введена. |
Где вызывается хук
wp-includes/link-template.php 244
$category_object = apply_filters( 'post_link_category', $cats[0], $cats, $post );