Advertisement
luisabarca

WP Dropdown Menu

Oct 26th, 2011
410
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.09 KB | None | 0 0
  1. <?php
  2. $taxonomy     = 'jobs_category';
  3. $orderby      = 'name';
  4. $show_count   = 1;      // 1 for yes, 0 for no
  5. $pad_counts   = 0;      // 1 for yes, 0 for no
  6. $hierarchical = 1;      // 1 for yes, 0 for no
  7. $title        = '';
  8.  
  9. $args = array(
  10.   'taxonomy'     => $taxonomy,
  11.   'orderby'      => $orderby,
  12.   'show_count'   => $show_count,
  13.   'hierarchical' => $hierarchical,
  14.   'title_li'     => $title
  15. );
  16. ?>
  17.  
  18. <ul>
  19. <?php wp_list_categories( $args ); ?>
  20. </ul>
  21.  
  22. <h2><?php _e('Categories:'); ?></h2>
  23. <form id="categoriesform" action="<?php bloginfo('url'); ?>" method="get">
  24.  
  25. <div>
  26. <?php $cats = get_categories($args); ?>
  27. <select id="categories">
  28. <?php foreach ($cats as $cat) : ?>
  29.     <option value="<?php echo get_term_link($cat, $cat->taxonomy) ?>"><?php echo $cat->name ?></option>
  30. <?php endforeach; ?>
  31. </select>
  32. <input type="submit" name="submit" value="view" />
  33. </div>
  34. </form>
  35.  
  36. <script>
  37. jQuery(document).ready(function()
  38. {
  39.     jQuery('#categoriesform').submit(function()
  40.     {
  41.         window.location = jQuery('#categories').val();
  42.         return false;
  43.     });
  44. });
  45. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement