Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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">
     jQuery(document).ready(function($){
      $("select#{$id}").change(function(){
        window.location.href = $(this).val();
      });
     });
    </script>
    SCRIPT;
      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>";
    }
    add_action('init','jquery_init');
    function jquery_init() {
      wp_enqueue_script('jquery');
    }

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

share|improve this question
1  
Do not redirect your visitor onChange. Without a mouse it will be very hard to get to the third item. –  toscho 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. –  Rahul Mar 3 at 6:03
    
@Rahul that would be a new question –  Tom J Nowell Mar 3 at 6:09

1 Answer 1

up vote 2 down vote accepted

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) {)

share|improve this answer
    
hey thanks it worked, it was so easy i didnt figured it out, thanks for your help –  ntechi Dec 10 '10 at 9:05

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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