Return to Snippet

Revision: 7169
at July 11, 2008 04:15 by gfazioli


Initial Code
<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>

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

Initial Description

                                

Initial Title
Menu combo category in WordPress 2.5.1

Initial Tags
javascript, php, wordpress

Initial Language
PHP