wp_dropdown_categories (using with taxonomy) defaults if no terms
|Reported by:||helgatheviking||Owned by:|
the default args for wp_dropdown_categories produce an empty select box when using wp_dropdown_categories for a taxonomy for which there are no terms. I produced this both w/ the filters on the edit.php screen (restrict_manage_posts) and on the front end in my theme. I presume this case never occurs with post categories as there is always Uncategorized.
$args = array( 'show_option_none' => , 'taxonomy' => 'featured', 'hide_if_empty' => false );
lines 340-343 in wp-includes/category-template.php are
if ( ! $r['hide_if_empty'] || ! empty($categories) ) $output = "<select name='$name' id='$id' class='$class' $tab_index_attribute>\n"; else $output = '';
so in a taxonomy that has no terms, the $categories variable is indeed empty, but the default arg is false, so the ! $rhide_if_empty? condition is satisfied and you get the opening of the select input, but you don't get any options therein (since they don't exist. and by default, you don't get any notice of such.
Change History (10)
5 years ago
- Component changed from General to Template
- Keywords has-patch added
5 years ago
- Cc xoodrew@… added