Skip to content

Instantly share code, notes, and snippets.

@joshuadavidnelson
Last active August 29, 2015 14:10
Show Gist options
  • Save joshuadavidnelson/545c2eedb4d533064f5c to your computer and use it in GitHub Desktop.
Save joshuadavidnelson/545c2eedb4d533064f5c to your computer and use it in GitHub Desktop.
Search for limited to a caetgory
<?php
// Search form, limited to category
echo '<form method="get" action=" ' . home_url() . '/">';
echo '<input type="text" size="16" name="s" placeholder="Search" />';
// This will limit the search to the year shown on the template, if the year query var is present
if( $year = get_query_var( 'yr' ) ) {
echo '<input type="hidden" name="year" id="year" value="' . $year . '" />';
}
echo '<input type="hidden" name="cat" id="cat" value="19" />'; // replace value with category id
echo '<input type="submit" value="Go" />';
echo '</form>';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment