I have an anchor link set up in my WordPress site which links from the navigation to the footer.
HTML – footer.php
<footer id="footer-anchor">
<div class="row">
...
The when the link is selected the page ‘jumps’ to the footer. I want it to animate down to the footer. Similar to how pages animated to the top with a ‘back to top’ button, but in reverse.
How about Page-Scroll-To-ID plugin ? It works fine in my WordPress website. We can set it up easily on admin page within minutes, and we done. This plugin is what you are looking for. Please check this link up Page-Scroll-To-ID plugin tutorial
Update : if you don’t want to use plug-ins, please follow these steps. We will use just purely jQuery plug-ins, and surprisingly, the code works like a charm and look simple !!!
1. Preparing your WordPress Theme
Wrap your menu with some class that we will use this one in a moment. For example:
Then add id to your specific element, but you have already add id to your
footer
element, which is#footer-anchor
.2. Coding your javascript, we will use only jQuery
3. Enqueue your script (include your script in WordPress’s way)
4. Run your website again
Congratulation !!!
I like to use this code from Karl Swedberg, I typically include it using a
<script></script>
in my footer.php file just before the</body>
tag or you could enqueue it in your functions.php file and have it load in the footer. I like this code because it removes the #hash from the URL once you click on the anchor.You can control the speed of the scroll by changing the number in this part of the code: