Skip to content

Instantly share code, notes, and snippets.

@csbeck
Created November 20, 2013 20:34
Show Gist options
  • Save csbeck/7570516 to your computer and use it in GitHub Desktop.
Save csbeck/7570516 to your computer and use it in GitHub Desktop.
Category search within a widget. Must include the PHP ability in widgets.
<!-- Search Form -->
<div style="margin:10px 0 10px 0;">
<form method="get" id="searchform" action="<?php echo esc_url( home_url( '/' ) ); ?>">
<table cellspacing="5">
<tr>
<td>
<label for="s" style="margin:10px;">Search in Categories</label>
</td>
<td>
<input type="text" class="field" name="s" style="width: 100px;"/>
</td>
<td>
<?php wp_dropdown_categories('show_count=1&hierarchical=1'); ?>
<!-- this shows both the count of posts and hierarchy format - change these to 0 if false -->
</td>
<td>
<input type="submit" class="submit" name="submit" id="searchsubmit" value="Search" style="display: block; position: relative;"/>
</td>
</tr>
</table>
</form>
</div>
<!-- Search Form -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment