admin管理员组文章数量:1130349
This is really bizarre - this has never happened before :/
I have a search.php template which consists of this...
<?php
/**
* @package WordPress
* @subpackage Example 2012
* @since Example 1.0
*/
get_header(); ?>
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
<?php the_title(); ?>
<?php endwhile; ?>
<?php endif; wp_reset_query(); ?>
<?php get_footer(); ?>
this is what is in my functions.php
// SEARCH FORM HEADER
function search_form_header( $form ) {
$form = '<form method="get" id="header-searchform" action="' . home_url( '/' ) . '" >
<div>
<div class="searchform-left"></div>
<input class="searchform-mid clearit" type="text" name="search" id="search-header" value="Search" />
<div class="searchform-right"></div>
</div>
</form>';
return $form;
}
add_filter( 'get_search_form', 'search_form_header' );
and this is how I'm calling my form...
<?php get_search_form('search_form_header'); ?>
And this is what my URL looks like when a search is performed (search query hello)...
/?search=hello
And all I get is the index.php?
And ideas would be truly amazing thanks. If you need more info please let me know thanks.
This is really bizarre - this has never happened before :/
I have a search.php template which consists of this...
<?php
/**
* @package WordPress
* @subpackage Example 2012
* @since Example 1.0
*/
get_header(); ?>
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
<?php the_title(); ?>
<?php endwhile; ?>
<?php endif; wp_reset_query(); ?>
<?php get_footer(); ?>
this is what is in my functions.php
// SEARCH FORM HEADER
function search_form_header( $form ) {
$form = '<form method="get" id="header-searchform" action="' . home_url( '/' ) . '" >
<div>
<div class="searchform-left"></div>
<input class="searchform-mid clearit" type="text" name="search" id="search-header" value="Search" />
<div class="searchform-right"></div>
</div>
</form>';
return $form;
}
add_filter( 'get_search_form', 'search_form_header' );
and this is how I'm calling my form...
<?php get_search_form('search_form_header'); ?>
And this is what my URL looks like when a search is performed (search query hello)...
http://www.example.co.uk/?search=hello
And all I get is the index.php?
And ideas would be truly amazing thanks. If you need more info please let me know thanks.
Share Improve this question edited Aug 13, 2012 at 18:05 kaiser 51k27 gold badges151 silver badges245 bronze badges asked Aug 13, 2012 at 17:58 JoshcJoshc 1,5207 gold badges24 silver badges41 bronze badges 2- Why the change from the core WordPress naming structure for the result in the URL string? As Chifliiiii suggested below, does your search result work if your change the input field to return "?s=hello" instead of "?search=hello" ? – Brent Commented Aug 13, 2012 at 19:07
- Don't know why I change this - but yep this is the problem. – Joshc Commented Aug 14, 2012 at 8:31
1 Answer
Reset to default 5Change the form to:
<input class="searchform-mid clearit" type="text" name="s" id="search-header" value="Search" />
Check that name should be "s" as that the get attribute wordpress use for search keyword
This is really bizarre - this has never happened before :/
I have a search.php template which consists of this...
<?php
/**
* @package WordPress
* @subpackage Example 2012
* @since Example 1.0
*/
get_header(); ?>
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
<?php the_title(); ?>
<?php endwhile; ?>
<?php endif; wp_reset_query(); ?>
<?php get_footer(); ?>
this is what is in my functions.php
// SEARCH FORM HEADER
function search_form_header( $form ) {
$form = '<form method="get" id="header-searchform" action="' . home_url( '/' ) . '" >
<div>
<div class="searchform-left"></div>
<input class="searchform-mid clearit" type="text" name="search" id="search-header" value="Search" />
<div class="searchform-right"></div>
</div>
</form>';
return $form;
}
add_filter( 'get_search_form', 'search_form_header' );
and this is how I'm calling my form...
<?php get_search_form('search_form_header'); ?>
And this is what my URL looks like when a search is performed (search query hello)...
/?search=hello
And all I get is the index.php?
And ideas would be truly amazing thanks. If you need more info please let me know thanks.
This is really bizarre - this has never happened before :/
I have a search.php template which consists of this...
<?php
/**
* @package WordPress
* @subpackage Example 2012
* @since Example 1.0
*/
get_header(); ?>
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
<?php the_title(); ?>
<?php endwhile; ?>
<?php endif; wp_reset_query(); ?>
<?php get_footer(); ?>
this is what is in my functions.php
// SEARCH FORM HEADER
function search_form_header( $form ) {
$form = '<form method="get" id="header-searchform" action="' . home_url( '/' ) . '" >
<div>
<div class="searchform-left"></div>
<input class="searchform-mid clearit" type="text" name="search" id="search-header" value="Search" />
<div class="searchform-right"></div>
</div>
</form>';
return $form;
}
add_filter( 'get_search_form', 'search_form_header' );
and this is how I'm calling my form...
<?php get_search_form('search_form_header'); ?>
And this is what my URL looks like when a search is performed (search query hello)...
http://www.example.co.uk/?search=hello
And all I get is the index.php?
And ideas would be truly amazing thanks. If you need more info please let me know thanks.
Share Improve this question edited Aug 13, 2012 at 18:05 kaiser 51k27 gold badges151 silver badges245 bronze badges asked Aug 13, 2012 at 17:58 JoshcJoshc 1,5207 gold badges24 silver badges41 bronze badges 2- Why the change from the core WordPress naming structure for the result in the URL string? As Chifliiiii suggested below, does your search result work if your change the input field to return "?s=hello" instead of "?search=hello" ? – Brent Commented Aug 13, 2012 at 19:07
- Don't know why I change this - but yep this is the problem. – Joshc Commented Aug 14, 2012 at 8:31
1 Answer
Reset to default 5Change the form to:
<input class="searchform-mid clearit" type="text" name="s" id="search-header" value="Search" />
Check that name should be "s" as that the get attribute wordpress use for search keyword
本文标签: searchphp template not loading results
版权声明:本文标题:search.php template not loading results 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://it.en369.cn/questions/1749220019a2334797.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。


发表评论