Plugin Author
malihu
(@malihu)
Hello,
The plugin provides the method to scroll the page programmatically, so you could do it by adding an extra js script.
For example, install/activate “Page scroll to id” and add the following script in your template (e.g. in footer.php below wp_footer() function):
<script>
(function($){
$(window).on("load",function(){
$.mPageScroll2id("scrollTo","#main");
});
})(jQuery);
</script>
You can set an offset if you want via the “Offset” option in plugin settings or you can set a specific offset only for the scrolling on page load, directly in the function:
<script>
(function($){
$(window).on("load",function(){
$.mPageScroll2id("scrollTo","#main",{
offset:100
});
});
})(jQuery);
</script>
Let me know if this helps
Thanks Malihu!
I activated the plugin and added this to the bottom of the functions.php file:
// Add scripts to wp_footer()
function child_theme_footer_script() { ?>
<script>
(function($){
$(window).on("load",function(){
$.mPageScroll2id("scrollTo","#main");
});
})(jQuery);
</script>
<?php }
add_action( 'wp_footer', 'child_theme_footer_script' );
I then cleared the site cache and browser cache, but it didn’t work.
I then tried changed “$.mPageScroll2id” to “$.m_PageScroll2id”, cleared caches, but that didn’t work either. I’m still working on debugging it now.
Thanks again,
FlexiThemes
Diregard my last post. I got it to work by just putting the code in footer.php below wp_footer() function, as your original post stated 🙂
Thanks again, Malihu!
Plugin Author
malihu
(@malihu)
You’re welcome 🙂
Yes, it’s better to place the code after wp_footer() function, as it requires the least amount of code with better performance 😉
I’m marking this as resolved but if you need more help let me know.