Filter hook 'list_cats'

in WP Core File wp-includes/category-template.php at line 454

View Source

list_cats

Filter Hook
Description
Filters a taxonomy drop-down display element. A variety of taxonomy drop-down display elements can be modified just prior to display via this filter. Filterable arguments include 'show_option_none', 'show_option_all', and various forms of the term name.

Hook Information

File Location wp-includes/category-template.php View on GitHub
Hook Type Filter
Line Number 454

Hook Parameters

Type Name Description
string $element Category name.
WP_Term|null $category The category object, or null if there's no corresponding category.

Usage Examples

Basic Usage
<?php
// Hook into list_cats
add_filter('list_cats', 'my_custom_filter', 10, 2);

function my_custom_filter($element, $category) {
    // Your custom filtering logic here
    return $element;
}

Source Code Context

wp-includes/category-template.php:454 - How this hook is used in WordPress core
<?php
 449  		}
 450  
 451  		if ( $parsed_args['show_option_none'] ) {
 452  
 453  			/** This filter is documented in wp-includes/category-template.php */
 454  			$show_option_none = apply_filters( 'list_cats', $parsed_args['show_option_none'], null );
 455  			$selected         = selected( $option_none_value, $parsed_args['selected'], false );
 456  			$output          .= "\t<option value='" . esc_attr( $option_none_value ) . "'$selected>$show_option_none</option>\n";
 457  		}
 458  
 459  		if ( $parsed_args['hierarchical'] ) {

PHP Documentation

<?php
/**
		 * Filters a taxonomy drop-down display element.
		 *
		 * A variety of taxonomy drop-down display elements can be modified
		 * just prior to display via this filter. Filterable arguments include
		 * 'show_option_none', 'show_option_all', and various forms of the
		 * term name.
		 *
		 * @since 1.2.0
		 *
		 * @see wp_dropdown_categories()
		 *
		 * @param string       $element  Category name.
		 * @param WP_Term|null $category The category object, or null if there's no corresponding category.
		 */
Quick Info
  • Hook Type: Filter
  • Parameters: 2
  • File: wp-includes/category-template.php
Related Hooks

Related hooks will be displayed here in future updates.