如何显示Wordpress搜索结果? [英] How to display Wordpress search results?
问题描述
我花了很多时间弄清楚为什么我的搜索无法在定制模板中进行.到目前为止,我已经能够弄清楚如何在我的标头中包含searchform.php文件,创建了当前为空的search.php文件(因此,当我搜索某些内容时,我被重定向到了空白页,我想我肯定是需要在search.php文件中进行某些操作才能使其正常运行),我正在阅读有关Wordpress Codex的所有内容,但找不到解决方案,只有我发现的有用信息就是这个.
I've spent a lot of time figuring out why my search is not working in my custom made template. So far I was able to figure out how to include searchform.php file in my header, created search.php file which is currently empty (so at the moment when I search for something I get redirected to a blank page and I think I definitely need something in search.php file to make it work), I was reading all around Wordpress codex but could not find a solution, only useful information I found was this.
http://codex.wordpress.org/Creating_a_Search_Page
您能否建议需要做些什么才能显示搜索结果?有特殊的查询,功能等吗?我真的在任何地方都找不到.
Can you suggest what need's to be done in order to display results of a search? is there a special query, function etc? I really can't find it anywhere.
我的 searchform.php 文件,以备不时之需.
my searchform.php file in case you need it.
<form action="<?php echo home_url(); ?>" id="search-form" method="get">
<input type="text" name="s" id="s" value="type your search" onblur="if(this.value=='')this.value='type your search'"
onfocus="if(this.value=='type your search')this.value=''" />
<input type="hidden" value="submit" />
</form>
推荐答案
基本上,您需要在search.php模板中包含Wordpress循环以遍历搜索结果并将其显示为模板的一部分.
Basically, you need to include the Wordpress loop in your search.php template to loop through the search results and show them as part of the template.
以下是
这篇关于如何显示Wordpress搜索结果?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!