Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › SPECIFIC PARAGRAPH
This topic contains 5 replies, has 2 voices, and was last updated by Ernest Marcinko 1 year, 9 months ago.
- AuthorPosts
- July 25, 2022 at 8:09 pm #38555
hello, I have created some service pages that have links with anchors that, by clicking, lead you to a specific paragraph on the same page.
I would like to know if with this plugin I can for example search for “online monitoring” and clicking will take me directly to the paragraph and not to the page …..
Here a sample page: https://moellerip.com/our-service/anti-counterfeiting/
a thousand thanks
Attachments:
You must be logged in to view attached files.July 26, 2022 at 10:09 am #38575Hi,
Well, there is a keyword highlighter feature, which can scroll to the first match of the keywords on the matching page. If the match is within the desired paragraph, then it should be able to scroll there automatically.
Searching the anchor and clicking it however is not going to work. That definitely needs custom coding to recognize the anchors and click them when needed.
I have coded a possible quick solution for you, but I don’t know if it works. Please set this exact keyword highlighter configuration first.
Add this code 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_footer_custom_script', 999999); function asp_footer_custom_script() { ?> <script> jQuery(function($){ setTimeout(function(){ let $parent = $('span[class*=asp_single_highlighted]').first().closest('a'); if ( $parent.is('a') && $parent.attr('href').indexOf('#') == 0 ) { $parent.get(0).click(); } }, 500); }); </script> <?php }
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
July 26, 2022 at 2:57 pm #38582Hi, thanks for your reply, I followed all the steps you suggested, but I don’t see any changes in the search bar, the result seems the same to me as before. Am I wrong something?
July 26, 2022 at 3:20 pm #38583Hi,
The configuration was incorrect, I corrected that, and the code was also missing from the snippets. I have added that, corrected the configuration, and tested like this: https://i.imgur.com/5vzStEM.png
Best,
It seems to be working on my end, the page scrolls to the anchor. However this may not work in all cases though.
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
July 26, 2022 at 3:35 pm #38585thanks you so much
July 27, 2022 at 11:56 am #38593You cannot access this content. Best,
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.