Menu combo categories in WordPress 2.5.1
Thursday, July 10, 2008 To create a menu / combo (tag select without a submit button and able to position themselves on the category currently displayed, you can use the following code:
- "event-dropdown" onchange = 'document.location.href=this.options[this.selectedIndex].value;' > <select name = "event-dropdown" onchange ='document.location.href=this.options[this.selectedIndex].value;'>
- <? Php
- single_cat_title ( '' , false ) ) : "" ) ; $ foo = ((is_category ())? (single_cat_title ('', false)): "");
- ) ; $option = '' ; $ categories = get_categories ( 'orderby = name & hierarchical = 0'); $ option ='';
- foreach ($ categories as $ cat) (
- $ option .= $ cat-> cat_name;
- $ option .= '('. $ cat-> category_count .')';
- $ option .= '</ option>';
- )
- echo $ option;
- ?>
The event onchange in tag select eliminates any submit button. Function WordPress is_category() however, you can determine whether we are seeing an "archive" categories, so as to obtain the title / name of the category displayed.













There are no comments for this post
Leave a comment