You didn’t add the dropdown/select name
attribute, that’s why it’s not working as expected. Please try updating your $dropdown_args
, here’s the updated arguments –
$dropdown_args = array(
'taxonomy' => 'cs_categories',
'id' => $this->get_field_id( 'cs-category' ),
'name' => $this->get_field_name( 'cs-category' ), // Added this line
'show_option_none' => __( 'Select category', 'text-domain' ),
'hide_empty' => true,
'hierarchical' => true,
'depth' => 2,
'echo' => 0,
'selected' => $instance[ 'cs-category' ],
'class' => 'widefat'
);