I have a custom searchform.php and search.php in my theme. However, when searching for something all I see is the front page (with mysite.com/?s=something in the adressbar). I use a filter to make Wordpress use my custom search form (don't know why it won't use it otherwise). The search does work when I use a different theme.
Filter code snippet in functions.php:
function search_form_no_filters() {
// look for local searchform template
$search_form_template = locate_template( 'searchform.php' );
if ( '' !== $search_form_template ) {
// searchform.php exists, remove all filters
remove_all_filters('get_search_form');
}
}
add_action('pre_get_search_form', 'search_form_no_filters');
My searchform.php
<form id="searchform" action="<?php echo home_url( '/' ); ?>" method="get" role="search">
<div class="input-group">
<input id="s" type="text" name="s" class="form-control">
<span class="input-group-btn">
<button class="btn" type="button" id="submit">Go</button>
</span>
</div>
<script>
jQuery(document).ready(function($){
$('#searchform #submit').on('click', function(){
$('#searchform').submit();
});
});
</script>
</form>
For debugging purposes I currently use search.php from the Twentyfourteen theme.
I've researched this problem and it seems that the most common mistake is that the search query input field has a name other than "s". I got that right though.
searchform.php
, and search using the default search form, does your Theme'ssearch.php
load properly? If you remove your custom filter, does your Theme'ssearch.php
load properly?search.php
, does the search results index load properly?