Advertisement
Guest User

Untitled

a guest
Feb 16th, 2012
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. <form action="<?php bloginfo('url'); ?>" method="get">
  2. <div>
  3. <?php
  4. $taxonomies = array('TAXONOMY NAME');
  5. $args = array('orderby'=>'name','hide_empty'=>true);
  6. $select = get_terms_dropdown($taxonomies, $args);
  7.  
  8. $select = preg_replace("#<select([^>]*)>#", "<select$1 onchange='return this.form.submit()'>", $select);
  9. echo $select;
  10. ?>
  11. <noscript><div><input type="submit" value="Näytä" /></div></noscript>
  12. </div></form>
  13. <?php
  14. function get_terms_dropdown($taxonomies, $args){
  15. $myterms = get_terms($taxonomies, $args);
  16. $output ="<select name='TAXONOMY SLUG'>";
  17. foreach($myterms as $term){
  18. $root_url = get_bloginfo('url');
  19. $term_taxonomy=$term->taxonomy;
  20. $term_slug=$term->slug;
  21. $term_name =$term->name;
  22. $link = $term_slug;
  23. $output .="<option value='".$link."'>".$term_name."</option>";
  24. }
  25. $output .="</select>";
  26. return $output;
  27. }
  28. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement