Menu combo category in WordPress 2.5.1


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. <select name="event-dropdown" onchange='document.location.href=this.options[this.selectedIndex].value;'>
  2. <option value="">Seleziona una categoria</option>
  3. <?php
  4. $foo = ( (is_category())?(single_cat_title('', false)):"" );
  5. $categories = get_categories('orderby=name&hierarchical=0'); $option = '';
  6. foreach ($categories as $cat) {
  7. $option .= '<option '.( ($cat->cat_name == $foo)?"selected":"" ).' value="/category/'.$cat->category_nicename.'">';
  8. $option .= $cat->cat_name;
  9. $option .= ' ('.$cat->category_count.')';
  10. $option .= '</option>';
  11. }
  12. echo $option;
  13. ?>
  14. </select>

URL: http://www.undolog.com/2008/07/10/menu-combo-categorie-in-wordpress-251/

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.