Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.