How do I set the default value of an exposed filter to a value that is not "-Any-"? I have a view with exposed filters, in Drupal 8. I need to set the default value of a filter to its title or custom text. I also need to unset/remove the - Any - option from the select list.

How can I achieve this?

Here is my code:

    function bootstrap_barrio_subtheme_form_alter(&amp;$form, FormStateInterface 
    $form_state, $form_id) {
        if ($form_state['view'] == 'office_locations_doctor_detail') {
            $form['field_doctor_reference_target_id_1']['#default_value'] = 
            'Select Doctor';
        }
     }


Cleared the cache and reload the page but nothing changed.
Try this:

/**
 * Implements hook_form_BASE_FORM_ID_alter().
 */
function bootstrap_barrio_subtheme_form_views_exposed_form_alter(&amp;$form, FormStateInterface $form_state, $form_id) {
  if ( $form_state-&gt;get('view')-&gt;id() == 'office_locations_doctor_detail'){
     // Set the default value as tid not the name of term.
     // Change 'Select Doctor' by the tid of it.
    $form['field_doctor_reference_target_id_1']['#default_value'] = '1';
    // Remove - Any - option. 
    unset($form['field_doctor_reference_target_id_1']['#options']['All']);
  }
}