Skip to content

Instantly share code, notes, and snippets.

@jazzsequence
Created September 1, 2014 16:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jazzsequence/e7166cadba43a97a18ac to your computer and use it in GitHub Desktop.
Save jazzsequence/e7166cadba43a97a18ac to your computer and use it in GitHub Desktop.
nps search form
<?php
function nps_get_taxonomy_search_form( $term = null, $taxonomy = null ) {
if ( !$term ) {
$term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) );
$term = $term->name;
}
if ( !$taxonomy )
$taxonomy = get_query_var( 'taxonomy' );
$form ='
<form role="search" method="get" class="search-form" action="' . get_home_url( '/' ) . '">
<label>
<input type="search" class="search-field" placeholder="Search" value="" name="s" title="Search for:" />
</label>
<input type="hidden" name="' . $taxonomy . '" value="' . $term . '" />
</form>
';
echo $form;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment