Category Dropdown

WordPress has a built-in display categories widget that can show as a list or a dropdown. However, it only shows categories with posts attached to them. If you want to show all categories in a dropdown use this code.

<form action=”<?php bloginfo(‘url’); ?>/” method=”get”>
$select = wp_dropdown_categories(‘show_option_none=Select State&show_count=1&orderby=name&echo=0&selected=0&hide_empty=0’);
$select = preg_replace(“#<select([^>]*)>#”, “<select$1 onchange=’return this.form.submit()’>”, $select);
echo $select;
<noscript><input type=”submit” value=”View” /></noscript>

You can find all the options that you can use on the following page:

Leave a Reply