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’re working hard on Advanced Custom Fields PRO 6.0, and Beta 1 is now available 🚀
— Advanced Custom Fields (@wp_acf) August 12, 2022
Featuring improved performance for Repeater fields with large datasets, and a new generation of ACF Blocks.
Let’s take a look 🧵https://t.co/Befre3kFAo
© 2022 Advanced Custom Fields.
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 Cookie Policy. If you continue to use this site, you consent to our use of cookies.