Home › Forums › Backend Issues (wp-admin) › Nested meta_query causing database to time out (or give HTTP error 502) › Reply To: Nested meta_query causing database to time out (or give HTTP error 502)
I’ve had a similar issue where my query had a lot of arrays;
'meta_query' => array(
'relation' => 'AND',
// array(
// 'key' => 'product_type',
// 'value' => $filterProductType,
// 'compare' => '=',
// ),
// array(
// 'key' => 'load_class',
// 'value' => $filterProductUsed,
// 'compare' => '=',
// ),
// array(
// 'key' => 'length_of_opening',
// 'value' => $lengthValue,
// 'compare' => '=',
// ),
// array(
// 'key' => 'width_of_opening',
// 'value' => $widthValue,
// 'compare' => '=',
// ),
// array(
// 'key' => 'depth',
// 'value' => $depthValue,
// 'compare' => '=',
// ),
array(
'key' => 'lockable',
'value' => $lockAble,
'compare' => 'LIKE',
),
array(
'key' => 'grating_opening_orientation',
'value' => $grateOpening,
'compare' => 'LIKE',
),
array(
'key' => 'cover_type',
'value' => $coverType,
'compare' => 'LIKE',
),
array(
'key' => 'enhanced_skid_resistance',
'value' => $enhancedSkid,
'compare' => 'LIKE',
),
array(
'key' => 'accessories',
'value' => $accessoriesOpt,
'compare' => 'LIKE',
),
array(
'key' => 'sealable',
'value' => $sealableOpt,
'compare' => 'LIKE',
),
array(
'key' => 'install_plus',
'value' => $installPlus,
'compare' => 'LIKE',
),
),
So been trying to do the above, however it doesn’t run the query anymore and comes back with no “products” found.
$results = array_unique ( array_intersect( $default_types, $first_result_types, $lockable_types, $grate_types ) );
$posts = new WP_Query( $results );
if ( $posts->have_posts() ){
while($posts->have_posts()){
$posts->the_post();
get_template_part( 'template-parts/content' );
}
}
else {
print '<h1>Sorry no products matched the filter</h1>';
}
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.