get_the_categories filter-hookWP 3.1.0

Filters the array of categories to return for a post.

Usage

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.

Changelog

Since 3.1.0 Introduced.
Since 4.4.0 Added the $post_id parameter.

Where the hook is called

get_the_category()
get_the_categories
wp-includes/category-template.php 98
return apply_filters( 'get_the_categories', $categories, $post_id );

Where the hook is used in WordPress

Usage not found.