我在WordPress中的搜索查询有问题。我有将近50种语言的语言数组。在该数组中,有一个“ ANY”选项 假设如果用户从下拉列表中选择“任何”选项,我想在搜索选项中包括所有语言。我没有用WordPress元查询来做到这一点。 任何帮助将不胜感激。
这是我的代码。
$meta_conditions = array();
$meta_conditions = array('relation' => 'AND');
$meta_conditions[] = array(
'key' => 'gender',
'value' => $pref_user_gender,
'compare' => '='
);
$meta_conditions[] = array(
'key' => 'user_account_status',
'value' => 'active',
'compare' => '=',
);
if ($pref_born_us_check == 'true') {
$meta_conditions[] = array(
'key' => 'born_in_us',
'value' => $pref_born_us,
'compare' => '='
);
}
if ($pref_citizen_us_check == 'true') {
$meta_conditions[] = array(
'key' => 'citizen_of_us',
'value' => $pref_citizen_of_us,
'compare' => '='
);
}
if ($pref_age_check == 'true') {
$meta_conditions[] = array(
'key' => 'age',
'value' => array($pref_min_age, $pref_max_age),
'type' => 'numeric',
'compare' => 'BETWEEN'
);
}
if ($pref_height_check == 'true') {
$meta_conditions[] = array(
'key' => 'height_member',
'value' => array($pref_min_height, $pref_max_height),
'compare' => 'BETWEEN'
);
}
if ($pref_smoking_check == 'true') {
$meta_conditions[] = array(
'key' => 'smoking',
'value' => $smoking,
'compare' => 'IN',
);
}
if ($pref_marital_status_check == 'true') {
$meta_conditions[] = array(
'key' => 'marital_status',
'value' => $marital_status,
'compare' => 'IN',
);
}
if ($pref_religion_check == 'true') {
$meta_conditions[] = array(
'key' => 'religion',
'value' => $religion,
'compare' => 'IN',
);
}
if ($pref_community_check == 'true') {
$meta_conditions[] = array(
'key' => 'community',
'value' => $community,
'compare' => 'IN',
);
}
if ($pref_language_check == 'true') {
$meta_conditions[] = array(
'key' => 'member_language',
'value' => $languages,
'compare' => 'IN',
);
}
if ($pref_state_check == 'true') {
$meta_conditions[] = array(
'key' => 'state',
'value' => $states,
'compare' => 'IN',
);
}
if ($pref_education_check == 'true') {
$meta_conditions[] = array(
'key' => 'education',
'value' => $education,
'compare' => 'IN',
);
}
if ($pref_diet_check == 'true') {
$meta_conditions[] = array(
'key' => 'diet',
'value' => $diet,
'compare' => 'IN',
);
}
if ($pref_drinking_check == 'true') {
$meta_conditions[] = array(
'key' => 'drinking',
'value' => $drinking,
'compare' => 'IN',
);
}
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$search_query_member_post = array(
'post_type' => 'member_post',
'posts_per_page' => 8,
'author__not_in' => $userid,
'post__not_in' => $unmatched_profiles,
'meta_query' => $meta_conditions,
'paged' => $paged,
);
$query = new WP_Query($search_query_member_post);
谢谢。