Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › Product taxonomy in asp_result_groups › Reply To: Product taxonomy in asp_result_groups
September 12, 2023 at 5:31 pm
#45359
Keymaster
The code seems to be incorrect. There is this knowledge base article on how to exactly use the asp_results_groups hook.
The main issue with your code is that you are tring to add items via query_posts to the live results list, however those are not compatible there. Instead of that, you should try ASP_Query. Something like:
$args = array(
's' => '',
'_ajax_search' => true,
'post_tax_filter' => array(
array(
'taxonomy' => 'product_cat',
'include' => array(123), // Taxonomy term ID here
'allow_empty' => false // Allow results, that does not have connection with this taxonomy
)
)
);
$asp_query = new ASP_Query($args);
$groupss = $asp_query->posts;