This website uses cookies to personalize your experience. By using this website you agree to our cookie policy.

Reply To: Get search phrase at asp_cpt_results filter

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

#38664
Ernest MarcinkoErnest Marcinko
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;
}