Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › Clicking on a suggested search keyword
This topic contains 5 replies, has 2 voices, and was last updated by Ernest Marcinko 10 months, 1 week ago.
- AuthorPosts
- September 15, 2023 at 11:43 am #45393
Hello!
My client requests that after clicking on a “suggested phrase” (Autocomplete & Suggestions -> Suggested search keywords), the page should be redirected to the search results page (with that keyword query) instead of opening the autocomplete popup.
Is this possible to do? I could not find any settings in the admin for this.Thank you in advance.
September 15, 2023 at 4:24 pm #45399Hi,
While there is no option to do that, it should be doable via a bit of custom code to trigger a redirection.
Try adding this code via the Code Snippets plugin or to the functions.php file in your theme/child theme directory – make sure to have a full server back-up first for safety. For more details you can check the safe coding guidelines.
Best,add_action('wp_footer', 'asp_add_footer_script', 99999); function asp_add_footer_script() { ?> <script> jQuery(function($){ $('.asp-try a').on('click', function(e){ let id = $(this).closest('.asp_w_container').data('id'); ASP.api(id, 'hideResults'); ASP.api(id, 'searchRedirect', jQuery(this).text()); }); }); </script> <?php }
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
September 18, 2023 at 10:48 am #45408Hello,
I am currently using woocommerce and want to redirect every search to the Woocommerce search results page.
I am using these settings: (See image attachment)
It works as expected when I hit enter or click on the magnifier icon, but thesearchRedirect
method from that snippet seems to ignore these settings and redirects me to the default wordpress search results page instead.Is there any way I can fix this?
Thanks in advance,
AdamAttachments:
You must be logged in to view attached files.September 18, 2023 at 1:58 pm #45413Sure, I think it’s still doable.
Please try this variation instead:
Best,add_action('wp_footer', 'asp_add_footer_script', 99999); function asp_add_footer_script() { ?> <script> jQuery(function($){ $('.asp-try a').on('click', function(e){ $(this).closest('.asp_w_container').find('.promagnifier').trigger('click'); }); }); </script> <?php }
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
September 18, 2023 at 2:17 pm #45418That does the job!
Thank you for your help! I think this ticket can be closed.
September 18, 2023 at 2:25 pm #45421You cannot access this content. Best,
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
- AuthorPosts
The topic ‘Clicking on a suggested search keyword’ is closed to new replies.