Hey ho everybody and thank you for viewing my code Snipp.
With this code you will able to remove empty exposed links.
Get raw version
php
/** * Implements hook_form_FORM_ID_alter(). */ function hook_form_views_exposed_form_alter(&$form, $form_state) { // Define important Variables $identifier = 'cat'; global $language; // prevent recursion - only execute once static $called = 0; if ($called === $form['#id']) { return; } $called = $form['#id']; // flag as called // Now we're checking each identifier on options $tids = array(); foreach ($form[$identifier]['#options'] as $key => $option) { if ($key != 'All') { $tids[$key]['tid'] = $key; // Checking if there is a entry it this tid in taxonomy_index // Joining the node table so we can check on language. $query = db_select('taxonomy_index', 't'); $query ->join('node', 'n', 't.nid = n.nid'); $query ->fields('t') ->fields('n') ->condition('t.tid', $key, '=') ->condition('n.language', $language->language, '=') ->condition('n.status', 1, '='); $result = $query->execute(); $tids[$key]['count'] = $result->rowCount(); // Removing the option without entrys if($tids[$key]['count'] == 0){ unset($form[$identifier]['#options'][$key]); } } } }