php - 如何将简单的 MySQL 查询转换为 WordPress 元查询
问题描述
我有一个 Wordpress 元查询,如下所述,我想通过另一个表中的另一个查询过滤这些帖子。
$meta_query_part['relation'] = 'AND';
$country_array =array();
$country_array['key'] = 'property_country';
$country_array['value'] = $search_string;
$country_array['type'] = 'CHAR';
$country_array['compare'] = 'LIKE';
$meta_query_part[] = $country_array;
$country_array =array();
$country_array['key'] = 'property_county';
$country_array['value'] = $search_string;
$country_array['type'] = 'CHAR';
$country_array['compare'] = 'LIKE';
$meta_query_part[] = $country_array;
$country_array =array();
$country_array['key'] = 'property_state';
$country_array['value'] = $search_string;
$country_array['type'] = 'CHAR';
$country_array['compare'] = 'LIKE';
$meta_query_part[] = $country_array;
$meta_query[]=$meta_query_part;
$args = array(
'cache_results' => false,
'update_post_meta_cache' => false,
'update_post_term_cache' => false,
'post_type' => 'estate_property',
'post_status' => 'publish',
'posts_per_page' => -1,
'meta_key' => 'prop_featured',
'orderby' => 'meta_value',
'order' => 'DESC',
'meta_query' => $meta_query,
);
$prop_selection = new WP_Query($args);
现在下面是另一个按价格范围过滤帖子的查询
SELECT post_id FROM `wp_prop_area_availability` WHERE price BETWEEN 34 AND 119
表来过滤帖子 我如何将 mysql 查询转换为 wordpress 元查询,或者换句话说,我有来自 wordpress 元查询的结果,我想按价格范围过滤这些结果,这个价格范围来自另一个表。
解决方案
推荐阅读
- reactjs - 如何让表单在 React 中提交后消失
- ssas - 将 MDX 转换为 DAX 查询时的性能问题
- python - PIL 是否能够修复截断的图像?如果没有,是否可以添加此功能?
- swift - 如何在 SwiftUI 中使用 NSAttributedString 和 ScrollView?
- postgresql - 获取基于月份的动态时区偏移
- typescript - TypeScript 声明对象结构而不使用 [key:string]
- python - ModuleNotFoundError:进行迁移时没有名为“my_app”的模块
- reactjs - 如何在打字稿中表示一个对象列表,其中键是日期,内容是数组?
- ggplot2 - ggplot2中x轴的第二个描述?
- reactjs - React 应用程序在转到页面时挂起并使用 300% 的 CPU