$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>wordpress meta query with multiple meta condition causing a load on server and slows down the server..!|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

wordpress meta query with multiple meta condition causing a load on server and slows down the server..!

matteradmin9PV0评论

I am writing a meta query with multiple conditions i want to check the conditions one by one it is working fine on the localhost but on the server it is affection and the server slows down and causing a page to refresh continuously. this query is running continuously on the server.

Here is the query :-

$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_age_check == 'true') {
    $meta_conditions[] = array(
        'key' => 'age',
        'value' => array($pref_min_age, $pref_max_age),
        '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_marital_status_check == 'true') {

    if (count($search_marital_status) > 0) {
        $meta_conditions[] = array(
            'key' => 'marital_status',
            'value' => $search_marital_status,
            'compare' => 'IN',
        );
    }


}

if ($pref_religion_check == 'true') {
    if (count($search_religion) > 0) {
        $meta_conditions[] = array(
            'key' => 'religion',
            'value' => $search_religion,
            'compare' => 'IN',
        );

    }

}


if ($pref_community_check == 'true') {

    if (count($search_community) > 0) {
        $meta_conditions[] = array(
            'key' => 'community',
            'value' => $search_community,
            'compare' => 'IN',
        );
    }

}

/*if ($pref_language_check == 'true') {
    if (count($search_languages) > 0) {
        $meta_conditions[] = array(
            'key' => 'member_language',
            'value' => $search_languages,
            'compare' => 'IN',
        );

    }

}*/

if ($pref_state_check == 'true') {

    if (count($search_states) > 0) {
        $meta_conditions[] = array(
            'key' => 'state',
            'value' => $search_states,
            'compare' => 'IN',
        );

    }

}

if ($pref_education_check == 'true') {

    if (count($search_education > 0)) {
        $meta_conditions[] = array(
            'key' => 'education',
            'value' => $search_education,
            'compare' => 'IN',
        );
    }

}

if ($pref_diet_check == 'true') {

    if (count($search_diet) > 0) {
        $meta_conditions[] = array(
            'key' => 'diet',
            'value' => $search_diet,
            'compare' => 'IN',
        );
    }

}


if ($pref_drinking_check == 'true') {

    if (count($search_drinking) > 0) {
        $meta_conditions[] = array(
            'key' => 'drinking',
            'value' => $search_drinking,
            'compare' => 'IN',
        );

    }

}

if ($pref_smoking_check == 'true') {

    if (count($search_smoking) > 0) {
        $meta_conditions[] = array(
            'key' => 'drinking',
            'value' => $search_smoking,
            'compare' => 'IN',
        );

    }

}

if ($pref_born_us_check == 'true') {
    $meta_conditions[] = array(
        'key' => 'pref_born_us',
        'value' => $pref_born_us,
        'compare' => '=',
    );
}

if ($pref_citizen_us_check == 'true') {
    $meta_conditions[] = array(
        'key' => 'pref_citizen_of_us',
        'value' => $pref_citizen_of_us,
        'compare' => '=',
    );
}

$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$search_query_member_post = array(
    'post_type' => 'member_post',
    'posts_per_page' => -1,
    'author__not_in' => $userid,
    'post__not_in' => $unmatched_profiles,
    'meta_query' => $meta_conditions,
    'paged' => $paged,
);

$query = new WP_Query($search_query_member_post);
Post a comment

comment list (0)

  1. No comments so far