Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › Shortcode in Search results not working › Reply To: Shortcode in Search results not working
August 17, 2020 at 9:33 am
#29000
Keymaster
Hi,
In short, you cannot enter shortcodes there. Most shortcodes are registered in a loop or single content sections, and may require additional parameters to work.
The only way you should try that, is programatically adding the shortcode to the content via the asp_results hook.
Something like this:
add_filter( 'asp_results', 'asp_add_custom_shortcode', 10, 1 );
function asp_add_custom_shortcode( $results ) {
foreach ($results as $k=>&$r) {
// Enter the shortcode into the quotes section
$r->content = do_shortcode('[my_shortoce_here]') . $r->content;
}
return $results;
}
Still, this may not work, as shortcodes should be optimally added inside the post editor directly, otherwise they might not process correctly.