поисковый запрос WordPress со значением мета-ключа - PullRequest
0 голосов
/ 27 ноября 2018

У меня проблема с поисковым запросом в WordPress.У меня есть массив языков, в котором почти 50 языков. В этом массиве есть опция «ЛЮБОЙ». Предположим, если пользователь выберет опцию «Любой» из выпадающего списка, я хочу включить все языки в опцию поиска.Я не понимаю, как это сделать с мета-запросом 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); 

Спасибо.

...