首页 > 解决方案 > 如何将简单的 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 元查询的结果,我想按价格范围过滤这些结果,这个价格范围来自另一个表。

标签: phpmysqlwordpress

解决方案


推荐阅读