Varying Search Result Pages

时间:2011-06-14 作者:Zach Shallbetter

我的网站上有两种不同的搜索结果,我想完全改变搜索结果页面的外观。我对搜索表单做了一些修改,但我不确定如何强制它重定向到另一个搜索。php如有任何帮助,将不胜感激

<form role="search" method="get" id="searchsupport" action="/">
    <label class="screen-reader-text" for="s">Search for:</label>
    <input type="text" onfocus="if (this.value == \'Search\')  
    {this.value = \'\';}" onblur="if (this.value == \'\')  
    {this.value = \'search\';}" id="s" name="s" value="search" class="search-form round"> 
    <input type="hidden" id="searchsubmit"> 
    <input type=\'hidden\' name=\'post_type\' value=\'software, documents\' />
</form>

1 个回复
最合适的回答,由SO网友:Bainternet 整理而成

您可以将隐藏字段添加到搜索表单中,并基于此添加其他模板:

<form role="search" method="get" id="searchsupport" action="/">
    <label class="screen-reader-text" for="s">Search for:</label>
    <input type="text" onfocus="if (this.value == \'Search\')  
    {this.value = \'\';}" onblur="if (this.value == \'\')  
    {this.value = \'search\';}" id="s" name="s" value="search" class="search-form round"> 
    <input type="hidden" id="searchsubmit"> 

    <!-- this is the magic field --->
    <input type="hidden" name="custom_search" value="1"> 

    <input type=\'hidden\' name=\'post_type\' value=\'software, documents\' />
</form>
然后在主题的搜索中。最顶端的php添加:

if (isset($_GET[\'custom_search\']) && $_GET[\'custom_search\'] == 1){
   include(\'custom_search.php\'); // change it to whatever template file you would like to use
   break;
}

结束

相关推荐

Intelligent Search Filtering

我需要一些关于搜索插件的帮助:WP自定义字段搜索。我有三个下拉菜单:1。城市2。郊区3。美食我需要的是,当你选择一个城市时,它会自动移动2。郊区与该城市相关。是一个自定义字段,即任何城市都可以有中国餐馆。郊区所以没关系,但只有某些城市的某些郊区。。。那么我该如何过滤任何想法呢?