Scroll results page to search term
-
I’ve used the Knowledge Base article Scroll results page to search term.
I’ve tried the “easy” way listed in the article and the other option listed in the comments to Levi.
My search terms are highlighted on the initial results page, but when you click on a result, it opens and defaults to the top of the page, so the user has to scroll down to attempt to locate what was actually returned in the search results.
This is the code I currently am trying (it’s the one from the comments to Levi)
`<?php
add_action( ‘wp_footer’, function() {
?>
<script>
jQuery(document).ready(function($) {
var offset = $(‘mark’).first().offset().top // use this line if you use <mark> tags
$(“html, body”).animate({ scrollTop: offset }, 100);
})
</script>
<?php
} );I am using the free version. Thank you!
The page I need help with: [log in to see the link]
- The topic ‘Scroll results page to search term’ is closed to new replies.