WordPress plugin: Zelig Dropdown Cats

This plugin displays the categories in the sidebar as a simple dropdown list (select box). Unlike the WP built-in dropdown_cats function, it gives the option to exclude some categories from the list.

I don’t know if there is already a similar plugin or if there is another way to do something like this, but it was funny to make and that’s enough for me!


  1. Download the zip file (current version is 1.4 of october 12, 2006).
  2. Extract the zelig-dropdown-cats.php file into the plugins directory in your WordPress installation (wp-content/plugins).
  3. Log in to WordPress administration. Go to the Plugins page and Activate this plugin.
  4. Put this code somewere in your template page, outside the loop (usually in sidebar):
<?php zelig_dropdown_cats(); ?>

IMPORTANT: if you are updating the plugin from version 1.0 or 1.1, please remove all the code formerly required at this point and leave only the function call, as indicated above.

The zelig_dropdown_cats() function has some parameters you can pass:

Parameter Values Description Default
sort_column name
sort list by name or id number id
sort_order asc
sorting direction of the list (ascending or descending) asc
file string name of the php file used to display selected categories (NOT WORKING!) index.php
hide_empty 0
1 means hide empty categories, 0 shows them too 1
exclude number or comma separated list of numbers these are the categories (ID numbers) to exclude from the list
post_count 0
if set to 1, display the count of posts in each category 0
title string text appearing in the list box when it’s closed. If you don’t want the first row as a title, use this parameter without any value (‘title=’) “Categories” (or corresponding localized text)
boxwidth number width size (in pixel) of the list box. If you don’t use this parameter or if you set it to 0, the list box will assume the width of the longest category name it contains. If you set a width value, longer names may be truncated at that point, depending on browser (IE6…) 0
child_of number If not set or if set to -1, shows all categories and subcategories. If set to 0, shows only main categories excluding all subcategories. If set with a category ID number, shows only its subcategories. -1


<?php zelig_dropdown_cats('sort_column=name'); ?>

displays list sorted by name.

<?php zelig_dropdown_cats('sort_column=name&exclude=1,3,5,6'); ?>

displays list sorted by name, excluding categories id 1, 3, 5 and 6.

<?php zelig_dropdown_cats('sort_order=desc&hide_empty=0'); ?>

displays list in descending ID order, showing also empty categories.

<?php zelig_dropdown_cats('title=Scegli una categoria&boxwidth=120'); ?>

shows “Select category” as a title in the list box and set the width to 120 pixels.

<?php zelig_dropdown_cats('title=&post_count=1&child_of=0'); ?>

don’t shows the first row with the title, adds the post count for every category and lists only main categories excluding subcategories.


The output code is valid XHTML Strict.
Tested with WordPress 1.5.2 and 2.0.x.


  • Version 1.4 (october 12, 2006): added “child_of” option to exclude the visualization of all subcategories or to show only subcategories of a given category. Another little upgrade lets you use more than one istance of the function in the same page.
  • Version 1.3 (august 26, 2006): now you can exclude the first row of the list with the title. Added localization support (translation of “Categories”, if available) as a default title.
  • Version 1.2 (august 14, 2006): semplified the code to put in the sidebar and added two new options “title” and “boxwidth”.
  • Version 1.1 (june 7, 2006): added “post_count” option to display a count of posts in each category after the name.
Informatica, Permalink

Abbiamo 130 commenti a questo articolo

  1. Pingback: Vindictive Bastard

Lascia un commento

Il tuo indirizzo email non sarà pubblicato. I campi obbligatori sono contrassegnati *

:smile: :grin: :mrgreen: :wink: :neutral: :sad: :cry: :eek: :confused: :cool: :lol: :razz: :oops: :mad: :evil: :twisted: :roll: :surprised: :!: :?: :idea: :arrow: :clap: :dance: :doh: :drool: :eh: :hand: :liar: :naughty: :pray: :shhh: :shifty: :sick: :silenced: :snooty: :think: :wall: :whistle: :love: :censored: :crazy: :food: :thumbup: :ciao: :cheers: :winky: :kiss: :rotfl: :ninja: