Scrolling back to the top of a long page can be tiring. A smooth scroll to top effect makes it easier. This guide will show you how to add this effect in WordPress using jQuery.
Why Add a Smooth Scroll to Top Effect?
A smooth scroll to top effect is user-friendly. It improves the user’s experience. They can easily return to the top of the page. This feature is important for long pages. It saves time and effort.

Credit: www.developerdrive.com
Steps to Add Smooth Scroll to Top Effect
Follow these steps to add the smooth scroll effect:
- Create a button for scrolling to the top.
- Add jQuery to your WordPress site.
- Write the jQuery code for smooth scrolling.
- Style the button with CSS.
Step 1: Create A Scroll To Top Button
First, create a button. This button will appear at the bottom of the page. When clicked, it will scroll to the top.
Go to your WordPress dashboard. Navigate to Appearance > Theme Editor. Open the footer.php file.
Add the following HTML code before the closing tag:
Scroll to Top Button
↑
This code creates a button with an upward arrow. You can change the symbol if you like.
Step 2: Add Jquery To Your WordPress Site
Next, add jQuery to your WordPress site. Most WordPress themes include jQuery by default. To be sure, add it manually.
Open the functions.php file. Add the following code to enqueue jQuery:
function enqueue_jquery() {
wp_enqueue_script('jquery');
}
add_action('wp_enqueue_scripts', 'enqueue_jquery');
This code ensures jQuery is available for use.
Step 3: Write The Jquery Code For Smooth Scrolling
Now, write the jQuery code. This code makes the button scroll to the top smoothly.
Open the footer.php file again. Add the following script before the closing tag:
This script does three things:
- Hides the button initially.
- Shows the button when the user scrolls down 100 pixels.
- Scrolls smoothly to the top when the button is clicked.
Step 4: Style The Button With Css
Finally, style the button to make it look nice. Open the style.css file. Add the following CSS code:
#scroll-to-top {
position: fixed;
bottom: 20px;
right: 20px;
display: none;
width: 50px;
height: 50px;
background-color: #000;
color: #fff;
text-align: center;
line-height: 50px;
border-radius: 5px;
z-index: 1000;
cursor: pointer;
}
#scroll-to-top:hover {
background-color: #555;
}
This CSS code styles the button. It positions it at the bottom-right corner. It also gives it a background color and some padding.

Credit: www.wpbeginner.com
Frequently Asked Questions
What Is Smooth Scroll To Top Effect In WordPress?
A smooth scroll to top effect allows users to smoothly scroll back to the top of the page.
Why Add A Smooth Scroll To Top In WordPress?
It enhances user experience by making navigation easier, especially on long pages.
How Does Jquery Help In Smooth Scroll?
JQuery simplifies the process of adding smooth scroll with its simple, cross-browser compatible code.
Is Jquery Needed For Smooth Scroll In WordPress?
Yes, jQuery provides an easy and efficient way to implement smooth scroll effects.
Conclusion
Adding a smooth scroll to top effect is easy. It improves user experience. Follow the steps above to add this feature to your WordPress site.
Remember to create a button, add jQuery, write the jQuery code, and style the button with CSS. Your users will thank you for making their browsing experience smoother.