Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › Adding shortcode or additional code to search results. › Reply To: Adding shortcode or additional code to search results.
November 9, 2020 at 10:12 am
#30197
Keymaster
Hi!
You are looking for the asp_results hook. That lets you make changes to the result items before they are printed.
To run a shortcode, you can use this sample to start with:
add_filter( 'asp_results', 'asp_custom_results_code', 10, 1 );
function asp_custom_results_code( $results ) {
foreach ($results as $k=>&$r) {
$r-content = do_shortcode('[shortcode_name post_id=' . $r->id . ']') . $r-content;
}
return $results;
}