wordpress - AND 关系在 Search and Filter Pro 使用 WP Query 的自定义搜索中不起作用
问题描述
我正在使用 Search and Filter Pro 插件根据各种帖子元和分类法获取搜索结果,我并没有完全使用插件的整个界面,只使用它的自定义查询方法:
https://searchandfilter.com/documentation/search-results/custom/
我将搜索和过滤器附加到该WP_Query
部分,如下所示:
$premium_args = array(
"s" => $_GET['q'],
'posts_per_page' => 20,
'paged' => 1,
'post_type' => array( 'contactdirectory'),
'orderby' => 'title',
'order' => 'ASC',
);
$premium_args['search_filter_id'] = 166;
在插件中,我AND
为该搜索和过滤器实例设置了“字段关系:”。
但是它没有按预期工作,这里有一个例子:
https://indiadairy.com/?s=&p_type=cd&_sft_Industries=equipment-manufacturers&_sfm_state=Maharashtra
_sft_Industries=equipment-manufacturers
在那里,然后但在搜索结果中,您可以看到某些结果对于分类法和“非政府组织”_sfm_state=Maharashtra
具有不同的值,而它应该只返回满足传递给两个参数的值的结果。Industries
Dairy Plants
我尝试添加
'meta_query' => array(
'relation' => 'AND',
)
它不起作用,正如我所料,因为它是用于在WP_Query
参数中手动传递的元查询。
解决方案
推荐阅读
- c# - 字典中不存在给定的键。mysql数据库c#中的错误
- java - Spring Boot 中的 @Schedule 不会在我们提供的日期运行
- libgdx - LibGDX - 检查指南针是否需要校准
- php - 来自 SQL 数据库的产品未显示在 Shopware 5 产品概览中
- android - Android共享库符号解析机制
- mysql - 如何结合 `MAX` 和 `JOIN` 以获得正确的输出?
- windows - (win10) Ndis 微型端口驱动程序,在 MpInitialize 之前未调用 EvtDeviceAdd
- django - 如何在 Django 模板标签中执行异常处理(try-catch)?
- c# - Swagger Auth 使用用户名和密码 .netcore 2
- kotlin - 如何将类类型传递给kotlin中的函数?