the_category_list
Filter HookDescription
Filters the categories before building the category list.Hook Information
File Location |
wp-includes/category-template.php
View on GitHub
|
Hook Type | Filter |
Line Number | 158 |
Hook Parameters
Type | Name | Description |
---|---|---|
WP_Term[]
|
$categories
|
An array of the post's categories. |
int|false
|
$post_id
|
ID of the post to retrieve categories for. When `false`, defaults to the current post in the loop. |
Usage Examples
Basic Usage
<?php
// Hook into the_category_list
add_filter('the_category_list', 'my_custom_filter', 10, 2);
function my_custom_filter($categories, $post_id) {
// Your custom filtering logic here
return $categories;
}
Source Code Context
wp-includes/category-template.php:158
- How this hook is used in WordPress core
<?php
153 *
154 * @param WP_Term[] $categories An array of the post's categories.
155 * @param int|false $post_id ID of the post to retrieve categories for.
156 * When `false`, defaults to the current post in the loop.
157 */
158 $categories = apply_filters( 'the_category_list', get_the_category( $post_id ), $post_id );
159
160 if ( empty( $categories ) ) {
161 /** This filter is documented in wp-includes/category-template.php */
162 return apply_filters( 'the_category', __( 'Uncategorized' ), $separator, $parents );
163 }
PHP Documentation
<?php
/**
* Filters the categories before building the category list.
*
* @since 4.4.0
*
* @param WP_Term[] $categories An array of the post's categories.
* @param int|false $post_id ID of the post to retrieve categories for.
* When `false`, defaults to the current post in the loop.
*/
Quick Info
- Hook Type: Filter
- Parameters: 2
- File: wp-includes/category-template.php
Related Hooks
Related hooks will be displayed here in future updates.