category_css_class
Filters the list of CSS classes to include with each category in the list.
Usage
add_filter( 'category_css_class', 'wp_kama_category_css_class_filter', 10, 4 ); /** * Function for `category_css_class` filter-hook. * * @param string[] $css_classes An array of CSS classes to be applied to each list item. * @param WP_Term $category Category data object. * @param int $depth Depth of page, used for padding. * @param array $args An array of wp_list_categories() arguments. * * @return string[] */ function wp_kama_category_css_class_filter( $css_classes, $category, $depth, $args ){ // filter... return $css_classes; }
- $css_classes(string[])
- An array of CSS classes to be applied to each list item.
- $category(WP_Term)
- Category data object.
- $depth(int)
- Depth of page, used for padding.
- $args(array)
- An array of wp_list_categories() arguments.
Changelog
Since 4.2.0 | Introduced. |
Where the hook is called
wp-includes/class-walker-category.php 245
$css_classes = implode( ' ', apply_filters( 'category_css_class', $css_classes, $category, $depth, $args ) );