i have a function of custom taxonomies to display a drop down list on my website, which is working fine, but there is one problem, the default value is a custom taxonomy, but that i dont want, i want a custom word, like select cause the current default value, when i select it, it is not redirecting to the corresponding page, if you wanna chaeck it, goto my website, on the home page i have kept that drop-down list www.mbas.in

and the code of the function is

function the_taxonomy_dropdown($taxonomy) {
      $id = "{$taxonomy}-dropdown";
      $js =<<<SCRIPT
    <script type="text/javascript">
        window.location.href = $(this).val();
      echo $js;
      $terms = get_terms($taxonomy);
      echo "<select name=\"{$id}\" id=\"{$id}\">";
      foreach($terms as $term) {
        echo '<option value="';
        echo get_term_link(intval($term->term_id),$taxonomy);
        echo '">' . "{$term->name}</option>";
      echo "</select>";
    function jquery_init() {

what i do for keeping default value as Select ????

  • 1
    Do not redirect your visitor onChange. Without a mouse it will be very hard to get to the third item.
    – fuxia
    Dec 10 '10 at 16:03
  • what if i want to use another drop down with diff taxonomy so that if user select anything from that drop down it redirects to the corresponding template.
    – user48408
    Mar 3 '14 at 6:03
  • @Rahul that would be a new question
    – Tom J Nowell
    Mar 3 '14 at 6:09

Not sure exactly what you're asking. Do you just want to include a blank value before the list of terms? Would this work:

echo '<option value="#"> - Select - </option>';

(inserted just before the line foreach($terms as $term) {)

  • hey thanks it worked, it was so easy i didnt figured it out, thanks for your help Dec 10 '10 at 9:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.