我正在寻找基于四个类别/分类的条件搜索帮助;国家/地区/卧室类型/数量。我想要的是一个下拉搜索功能,当我选择一个特定的国家时,只有该国家的地区才会出现在“地区”下拉列表中,而在“类型”下拉列表中,只有该特定地区的可用类型才会列出。我显然准备为定制支付费用。约翰
conditional search
1 个回复
SO网友:wdalhaj
解决方案1:
这可以通过在搜索表单中添加下拉菜单来完成。eg cat\\U slct
如果主题中不存在搜索模板,请创建搜索模板。
在页面顶部和后面直接添加if语句get_header();
-
if(isset($_POST[\'cat_slct\'])){
//make the query using the name of the categoty you\'v just received via $_POST[].
//or search within the database if necessary using the $wpdb object,it helps a lot.
}
}else{
//the search page as its without modifying.
//just you have to add the closing else tag before the get_footer();
}//right before the get_footer()
解决方案2:与解决方案1相同,但这次您将创建一个页面模板,并将其称为custom\\u search。
现在继续创建一个使用自定义页面模板的页面。。例如,将其命名为search\\u cats。
与此不同的是,您将目标搜索表单的操作设置到此页面。
与之前一样:获取发布的数据并将其插入查询,然后执行常规循环。
结束