SPECIFIC PARAGRAPH

This topic contains 5 replies, has 2 voices, and was last updated by Ernest Marcinko Ernest Marcinko 1 year, 9 months ago.

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #38555
    raffo
    raffo
    Participant

    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.
    #38575
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi,

    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.

    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
    }
    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #38582
    raffo
    raffo
    Participant

    Hi, 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?

    #38583
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi,

    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
    It seems to be working on my end, the page scrolls to the anchor. However this may not work in all cases though.

    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #38585
    raffo
    raffo
    Participant

    thanks you so much

    #38593
    Ernest Marcinko
    Ernest Marcinko
    Keymaster
    You cannot access this content. Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.