Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › Adding shortcode or additional code to search results.
This topic contains 1 reply, has 2 voices, and was last updated by Ernest Marcinko 2 years, 4 months ago.
- AuthorPosts
- November 7, 2020 at 7:56 pm #30190
Hi there.
I have looked through the available filters and the plugin API and can’t seem to find what I’m looking for. If I have…please point me in the right direction 🙂I would like to add a short code, or regular PHP code, into the info that is included in each search result box. So when my searches come up I can have title, content, date, etc….and I see how to modify that through your panel… I want to add a shortcode for a bookmark app so as you scroll through results you can add them to a favorites list…a la the Netflix UI. I can’t see where to actually add a code snippet with a filter or through the control panel.
Thank you for your time.
Gabe
November 9, 2020 at 10:12 am #30197Hi!
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:
Best,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; }
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
- AuthorPosts
You must be logged in to reply to this topic.