Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › terms filter on custom page › Reply To: terms filter on custom page
All right, I have a possible solution!
1. First off, you need to put a custom code snippet into the functions.php file in your theme directory:
add_filter('asp_query_is_search', function($is_search, $wp_query){
if ( isset($wp_query->query_vars) && isset($wp_query->query_vars['asp_override']) ) {
return true;
}
return $is_search;
}, 10, 2);
This will listen to an additional query parameter and trigger an override to the loop when detected.
2. In your loop template replace these lines:
$args = array(
'post_type' => 'product', // Ensure you're querying WooCommerce products
'post__in' => $product_ids_array,
'orderby' => 'post__in', // Preserve the order from the JetEngine query
'posts_per_page' => -1, // Adjust the number of products as needed
);
with this:
if ( isset($_GET['p_asp_data']) ) {
// Query arguments to signal Ajax Search Pro for override
$args = array(
'post_type' => 'product',
'asp_override' => true,
);
} else {
// Original WP_Query arguments
$args = array(
'post_type' => 'product', // Ensure you're querying WooCommerce products
'post__in' => $product_ids_array,
'orderby' => 'post__in', // Preserve the order from the JetEngine query
'posts_per_page' => -1, // Adjust the number of products as needed
);
}
This will trigger the signal, whenever a live search query is detected.
3. Finally, add the asp_es_3 CSS class to the the product-card loop container, like so: https://i.imgur.com/i927SBK.png
This ensures that Ajax Search Pro knows where the template is rendered so the replacement is made correctly.
That’s it, this should do the trick!