Posted By

gfazioli on 07/11/08


Tagged

javascript php wordpress


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

gfazioli


Menu combo category in WordPress 2.5.1


 / Published in: PHP
 

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

  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>

Report this snippet  

You need to login to post a comment.