Trying to remove options form an exposed filter In drupal 7, I'm trying to remove an exposed taxonomy filter. This taxonomy filter has a depth of 2. I'm only trying to expose the parent item. 

As a quick fix I'm trying (poorly) to remove them with the following theme function below. 

&lt;?php
function theme_preprocess_views_exposed_form(&amp;$vars, $hook) {

    //  views-exposed-form-instructor-profile-list-page
    switch($vars['form']['#id']) {

        // instructor profile       
        case 'views-exposed-form-instructor-profile-list-page':
            foreach ($vars['form']['term_node_tid_depth']['#options'] as $option) { 
                foreach ($option-&gt;option as $key=&gt;$v) {
                        if (stristr($v, '-')) {
                            print $v . '&lt;br&gt;';
                            $vars['form']['term_node_tid_depth']['#options']['option'][$key] = 'FILTERED';
                        }
                }
            }           

            print_r($vars['form']['term_node_tid_depth']['#options']['option']);
            break;

        // do nothing
        default:



    }
}


In the end I'm trying to figure out what exactly to unset() any option that begins with '- child item'.
Instead try the following it will help you by using hook_form_alter()

function mymodule_form_views_exposed_form_alter(&amp;$form, &amp;$form_state, $form_id) {

  if($form['#id'] == 'views-exposed-form-[your-view-here]') {

    foreach ($form['tid']['#options'] as $term_key =&gt; $term) {

      // Check if this isn't the 'ANY' option
      if($term_key !== 'All') {
        // Check if this is a child by looking for '-' as first char in string
        $term_value = reset($term-&gt;option);
        if($term_value[0] == '-') {
          unset($form['tid']['#options'][$term_key]);
        }
      }

    }

  }

}


taken from the source