I have a dropdown menu for selecting categories in a widget that I am working on. Everything is working and options are being saved in the database. What I am trying to do now is add a blank option instead of it being automatically set when you click save. In this situation, the user might not want to set a category.
$this->categories = get_categories();
foreach ( $this->categories as $cat ) {
$selected = ( $cat->term_id == esc_attr( $category ) ) ? ' selected = "selected" ' : '';
$option = '<option '.$selected .'value="' . $cat->term_id;
$option = $option .'">';
$option = $option .$cat->name;
$option = $option .'</option>';
echo $option;
}
How can I append a blank option to the select?