wp-includes/category-template.php:344Displays or retrieves the HTML dropdown list of categories.
$argsarray|stringoptional''$show_option_allstringdefault: empty
$show_option_nonestringdefault: empty
$option_none_valuestringdefault: empty
$orderbystringdefault: 'id' (term_id)
$pad_countsbooldefault: false
$show_countbool|intdefault: 0
$echobool|intdefault: 1
$hierarchicalbool|intdefault: 0
$depthintdefault: 0
$tab_indexintdefault: 0 (no tabindex)
$namestringdefault: 'cat'
$idstring
$classstringdefault: 'postform'
$selectedint|stringdefault: 0
$value_fieldstringdefault: 'term_id'
$taxonomystring|arraydefault: 'category'
$hide_if_emptybooldefault: false (create select element even if no categories are found)
$requiredbooldefault: false
$walkerWalkerdefault: empty which results in a Walker_CategoryDropdown instance being used
$aria_describedbystringdefault: empty string
string4 hooks fire while wp_dropdown_categories() runs, in this order:
Filters a taxonomy drop-down display element.
Filters a taxonomy drop-down display element.
Filters a taxonomy drop-down display element.
Filters the taxonomy drop-down output.
function wp_dropdown_categories( $args = '' ) { $defaults = array( 'show_option_all' => '', 'show_option_none' => '', 'orderby' => 'id', 'order' => 'ASC', 'show_count' => 0, 'hide_empty' => 1, 'child_of' => 0, 'exclude' => '', 'echo' => 1, 'selected' => 0, 'hierarchical' => 0, 'name' => 'cat', 'id' => '', 'class' => 'postform', 'depth' => 0, 'tab_index' => 0, 'taxonomy' => 'category', 'hide_if_empty' => false, 'option_none_value' => -1, 'value_field' => 'term_id', 'required' => false, 'aria_describedby' => '', ); $defaults['selected'] = ( is_category() ) ? get_query_var( 'cat' ) : 0; // Back compat. if ( isset( $args['type'] ) && 'link' === $args['type'] ) { _deprecated_argument( __FUNCTION__, '3.0.0', sprintf( /* translators: 1: "type => link", 2: "taxonomy => link_category" */ __( '%1$s is deprecated. Use %2$s instead.' ), '<code>type => link</code>', '<code>taxonomy => link_category</code>' ) ); $args['taxonomy'] = 'link_category'; } // Parse incoming $args into an array and merge it with $defaults. $parsed_args = wp_parse_args( $args, $defaults ); $option_none_value = $parsed_args['option_none_value']; if ( ! isset( $parsed_args['pad_counts'] ) && $parsed_args['show_count'] && $parsed_args['hierarchical'] ) { $parsed_args['pad_counts'] = true; } $tab_index = $parsed_args['tab_index']; $tab_index_attribute = ''; if ( (int) $tab_index > 0 ) { $tab_index_attribute = " tabindex=\"$tab_index\""; } // Avoid clashes with the 'name' param of get_terms(). $get_terms_args = $parsed_args; unset( $get_terms_args['name'] ); $categories = get_terms( $get_terms_args ); $name = esc_attr( $parsed_args['name'] ); $class = esc_attr( $parsed_args['class'] ); $id = $parsed_args['id'] ? esc_attr( $parsed_args['id'] ) : $name; $required = $parsed_args['required'] ? 'required' : ''; $aria_describedby_attribute = $parsed_args['aria_describedby'] ? ' aria-describedby="' . esc_attr( $parsed_args['aria_describedby'] ) . '"' : ''; if ( ! $parsed_args['hide_if_empty'] || ! empty( $categories ) ) { $output = "<select $required name='$name' id='$id' class='$class'$tab_index_attribute$aria_describedby_attribute>\n"; } else { $output = ''; } if ( empty( $categories ) && ! $parsed_args['hide_if_empty'] && ! empty( $parsed_args['show_option_none'] ) ) { /** * Filters a taxonomy drop-down display element.Introduced in 6.1.0. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
src/wp-includes/category-template.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.