W3cubDocs

/WordPress

apply_filters( ‘post_link_category’, WP_Term $cat, array $cats, WP_Post $post )

Filters the category that gets used in the %category% permalink token.

Parameters

$catWP_Term
The category to use in the permalink.
$catsarray
Array of all categories (WP_Term objects) associated with the post.
$postWP_Post
The post in question.

Source

$category_object = apply_filters( 'post_link_category', $cats[0], $cats, $post );

Changelog

Version Description
3.5.0 Introduced.

© 2003–2024 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/hooks/post_link_category