wp_dropdown_categories() function


#1

Hi Devs,

Been struggling to achieve on this… I am using wp_dropdown_categories() and then everytime my show_option_none is set, the value is always set to -1 my question is how to set it as “empty”

current html code

<option value="-1">City</option>
it should be display like this
<option value="">City</option>

here’s my code below…

$args = array( 'show_option_all' => '', 'show_option_none' => __('City', 'textdomain'), 'option_none_value' => '-1', 'show_count' => 0, 'hide_empty' => 0, 'child_of' => 0, 'echo' => 1, 'selected' => 0, 'hierarchical' => 0, 'name' => 'city', 'id' => 'city', 'class' => 'postform', 'depth' => 0, 'tab_index' => 0, 'taxonomy' => 'city', 'hide_if_empty' => false, 'value_field' => 'slug', ); wp_dropdown_categories( $args );

Thansk for the help!


#2

option_none_value = '' fixed my issue… the other issue now is it will not add selected='selected'