Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › Get search phrase at asp_cpt_results filter › Reply To: Get search phrase at asp_cpt_results filter
August 3, 2022 at 2:49 pm
#38664
Keymaster
Hi,
I just checked, and there is an error in the core code with that specific filter. The wrong variable is passed, and so the args are not accessible. You can however use this filter instead:
add_filter( 'asp_results', 'asp_custom_link_results', 10, 4 );
function asp_custom_link_results( $results, $search_id, $is_ajax, $args ) {
$link = $args['s'];
// Parse through each result item
foreach ($results as $k=>&$r) {
// Only post type results
if ( isset($r->post_type) ) {
// Do your thing here
}
}
return $results;
}