/ Published in: PHP
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<select name="event-dropdown" onchange='document.location.href=this.options[this.selectedIndex].value;'> <option value="">Seleziona una categoria</option> <?php $foo = ( (is_category())?(single_cat_title('', false)):"" ); $categories = get_categories('orderby=name&hierarchical=0'); $option = ''; foreach ($categories as $cat) { $option .= '<option '.( ($cat->cat_name == $foo)?"selected":"" ).' value="/category/'.$cat->category_nicename.'">'; $option .= $cat->cat_name; $option .= ' ('.$cat->category_count.')'; $option .= '</option>'; } echo $option; ?> </select>
URL: http://www.undolog.com/2008/07/10/menu-combo-categorie-in-wordpress-251/