Home › Forums › Front-end Issues › Meta query hanging on admin-ajax
I’m hoping someone can point me in the right direction please, I’ve got a search query that becomes a filter.
On the filter page locally it works great! However when testing on server, the admin-ajax.php hangs and then crashes….
Here is my query;
function custom_filter_query( $query ) {
$filterProductType = $_POST['filterProductType'];
$filterProductUsed = $_POST['filterProductUsed'];
$lengthValue = $_POST['lengthValue'];
$widthValue = $_POST['widthValue'];
$depthValue = $_POST['depthValue'];
$lockAble = $_POST['lockAble'];
$grateOpening = $_POST['grateOpening'];
$coverType = $_POST['coverType'];
$enhancedSkid = $_POST['enhancedSkid'];
$accessoriesOpt = $_POST['accessoriesOpt'];
$sealableOpt = $_POST['sealableOpt'];
$args = array(
'numberposts' => 999,
'post_type'=> 'products',
'orderby' => 'title',
'order' => 'ASC',
'post_status' => array('publish'),
'posts_per_page'=> '999',
'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',
),
),
);
$posts = new WP_Query( $args );
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>';
}
wp_die();
}
I’ve read articles similar but been unable to pinpoint what’s causing it or how to get around it. I think it’s because it’s a lot of meta_queries
but the user needs the option to select possibility all of them.
Any ideas?
You must be logged in to reply to this topic.
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!
Are you building WordPress sites with ACF and @BeaverBuilder, and wanted to use your ACF Blocks in both the block editor and Beaver Builder?
— Advanced Custom Fields (@wp_acf) May 10, 2023
The BB team recently added support for using ACF Blocks in Beaver Builder. Check it out 👇https://t.co/UalEIa5aQi
© 2023 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.