WordPress tutorials: Search category with dropdown

Wpsnipp – Displays a hierarchical category dropdown list in HTML form with a submit button, in a WordPress sidebar unordered list, with a count of posts in each category. Adding this to your wordpress theme will allow users to select a category to search.



<form role="search" method="get" id="searchform" action="<?php bloginfo('siteurl'); ?>">
<label class="screen-reader-text" for="s">Search for:</label>
<input type="text" value="" name="s" id="s" />
in <?php wp_dropdown_categories( 'show_option_all=All Categories' ); ?>
<input type="submit" id="searchsubmit" value="Search" />

Leave a comment