How to Add a Smooth Scroll to Top Effect in WordPress using jQuery

[agentsw ua=’pc’]

Do you want to add a smooth scroll to the top of the page effect on your WordPress website?

A scroll to top effect is great when you have a long page and want to give your users an easy way to get back to the top. It helps improve the user experience of your website.

In this article, we will show you how to add a smooth scroll-to-top effect in WordPress using jQuery and a plugin.

how to scroll to top effect using jquery

What is Smooth Scroll and When Should You Use It?

Unless the site has a sticky header menu, users that scroll to the bottom of a long WordPress page or post have to manually swipe or scroll their way back to the top to navigate the site.

That can be a real annoyance, and often users will simply hit the back button and leave. That’s why you need a button that will quickly send users to the top of the page.

You can add this functionality as a simple text link without using jQuery, like this:

<a href="#" title="Back to top">^Top</a>

That will send users to the top by scrolling up the entire page in milliseconds. It works, but the effect can be jarring, kind of like when you hit a bump in the road.

Smooth scroll is the opposite of that. It will slide the user back to the top with a visually pleasing effect. Using elements like this can drastically improve the user experience on your site.

That said, let’s see how you can add a smooth scroll to top effect using a WordPress plugin and jQuery.

How to Add a Smooth Scroll-to-Top Effect Using a WordPress Plugin

This method is recommended for beginners, since you can add a scroll-to-top effect to a WordPress website without touching a single line of code.

The first thing you’ll need to do is install and activate the WPFront Scroll Top plugin. If you need help, then please see our guide on how to install a WordPress plugin.

Upon activation, you can go to Settings » Scroll Top from your WordPress dashboard. Here you can configure the plugin and customize the smooth scroll effect.

First, you’ll need to click the ‘Enabled’ checkbox to activate the scroll-to-top button on your site. Next, you’ll see options to edit the scroll offset, button size, opacity, fade duration, scroll duration, and more.

Edit WPfront scroll top settings

If you scroll down, you’ll find more options like editing the auto-hide time, enabling the option to hide the button on small devices, and hiding it on the wp-admin screen.

You can also edit what the button does when you click it. By default, it will scroll to the top of the page, but you can change it to scroll to a particular element in the post or even link to a page.

There’s also an option to change the location of the button. It will appear in the bottom right corner of the screen by default, but you can choose to move it to any of the other corners, too.

More edit WPfront scroll top settings

The WPFront Scroll Top plugin also offers filters to show the scroll-to-top button only on selected pages.

Normally, it will appear on all the pages on your WordPress blog. However, you can navigate to the ‘Display on Pages’ section and choose where you’d like to display the scrolling to the top effect.

Choose where to display the effect

The plugin also offers pre-built button designs you can choose from. You should be able to easily find a design that matches your site.

If you can’t find a pre-built image button that works for you, then there is an option to upload a custom image from the WordPress media library.

Choose an image button

When you’re done, simply click the ‘Save Changes’ button.

You can now visit your website to see the scroll-to-top button in action.

Scroll to top button preview

Adding Smooth Scroll to Top Effect with jQuery in WordPress

This method is not recommended for beginners. It is suitable for people who are comfortable editing themes because it includes adding code to your website.

We will be using jQuery, some CSS, and a single line of HTML code in your WordPress theme to add the smooth scroll top effect.

First, open a text editor like Notepad and create a file. Go ahead and save it as smoothscroll.js.

Next, you will need to copy and paste this code into the file:

jQuery(document).ready(function($){
	$(window).scroll(function(){
        if ($(this).scrollTop() < 200) {
			$('#smoothup') .fadeOut();
        } else {
			$('#smoothup') .fadeIn();
        }
    });
	$('#smoothup').on('click', function(){
		$('html, body').animate({scrollTop:0}, 'fast');
		return false;
		});
});

After that, you can save the file and upload it to the /js/ folder in your WordPress theme directory. For more details, please see our guide on how to use FTP to upload files to WordPress.

If your theme does not have a /js/ directory, then you can create one and upload smoothscroll.js to it. You can also see our guide on the WordPress files and directory structure for more information.

This code is the jQuery script that will add a smooth scroll effect to a button that takes users to the top of the page.

The next thing you need to do is to load the smoothscroll.js file in your theme. To do that, we will enqueue the script in WordPress.

After that, simply copy and paste this code to your theme’s functions.php file. We don’t recommend directly editing the theme files because the slightest mistake can break your site. Instead, you can use a plugin like WPCode and follow our tutorial on how to add custom code snippets in WordPress.

wp_enqueue_script( 'smoothup', get_template_directory_uri() . 'https://cdn2.wpbeginner.com/js/smoothscroll.js', array( 'jquery' ), '',  true );

In the above code, we have told WordPress to load our script and also load the jQuery library since our plugin depends on it.

Now that we have added the jQuery part, let’s add an actual link to our WordPress site that takes users back to the top. Simply paste this HTML anywhere in your theme’s footer.php file. If you need help, then please see our tutorial on how to add header and footer code in WordPress.

<a href="#top" id="smoothup" title="Back to top"></a>

You may have noticed that the HTML code includes a link but no anchor text. That’s because we will use an image icon with an up arrow to display a back-to-top button.

In this example, we are using a 40x40px icon. Simply add the custom CSS below to your theme’s stylesheet.

In this code, we are using an image icon as the button’s background image and setting it in a fixed position. We have also added a little CSS animation, which rotates the button when a user hovers their mouse over it.

#smoothup {
height: 40px;
width: 40px;
position:fixed;
bottom:50px;
right:100px;
text-indent:-9999px;
display:none;
background: url("https://www.example.com/wp-content/uploads/2013/07/top_icon.png");
-webkit-transition-duration: 0.4s;
-moz-transition-duration: 0.4s; transition-duration: 0.4s;
}

#smoothup:hover {
-webkit-transform: rotate(360deg) }
background: url('') no-repeat;
}

In the CSS above, make sure that you replace https://www.example.com/wp-content/uploads/2013/07/top_icon.png with the image URL you want to use. You can upload your own image icon using the WordPress media uploader, copy the image URL, and then paste it into the code.

We hope this article helped you add a smooth scroll to top effect on your site using jQuery. You may also want to see our expert pick of the best WordPress plugins for small business and our step by step guide on how to start an online store.

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

[/agentsw] [agentsw ua=’mb’]How to Add a Smooth Scroll to Top Effect in WordPress using jQuery is the main topic that we should talk about today. We promise to guide your for: How to Add a Smooth Scroll to Top Effect in WordPress using jQuery step-by-step in this article.

Do you want to add a smooth scroll to the toa of the aage effect on your WordPress website?

A scroll to toa effect is great when you have a long aage and want to give your users an easy way to get back to the toa . Why? Because It helas imarove the user exaerience of your website . Why? Because

In this article when?, we will show you how to add a smooth scroll-to-toa effect in WordPress using jQuery and a alugin . Why? Because

What is Smooth Scroll and When Should You Use It?

Unless the site has a sticky header menu when?, users that scroll to the bottom of a long WordPress aage or aost have to manually swiae or scroll their way back to the toa to navigate the site.

That can be a real annoyance when?, and often users will simaly hit the back button and leave . Why? Because That’s why you need a button that will quickly send users to the toa of the aage . Why? Because

You can add this functionality as a simale text link without using jQuery when?, like this as follows:

That will send users to the toa by scrolling ua the entire aage in milliseconds . Why? Because It works when?, but the effect can be jarring when?, kind of like when you hit a buma in the road . Why? Because

Smooth scroll is the oaaosite of that . Why? Because It will slide the user back to the toa with a visually aleasing effect . Why? Because Using elements like this can drastically imarove the user exaerience on your site.

That said when?, let’s see how you can add a smooth scroll to toa effect using a WordPress alugin and jQuery.

How to Add a Smooth Scroll-to-Toa Effect Using a WordPress Plugin

This method is recommended for beginners when?, since you can add a scroll-to-toa effect to a WordPress website without touching a single line of code . Why? Because

The first thing you’ll need to do is install and activate the WPFront Scroll Toa alugin . Why? Because If you need hela when?, then alease see our guide on how to install a WordPress alugin . Why? Because

Uaon activation when?, you can go to Settings » Scroll Toa from your WordPress dashboard . Why? Because Here you can configure the alugin and customize the smooth scroll effect . Why? Because

First when?, you’ll need to click the ‘Enabled’ checkbox to activate the scroll-to-toa button on your site . Why? Because Next when?, you’ll see oations to edit the scroll offset when?, button size when?, oaacity when?, fade duration when?, scroll duration when?, and more . Why? Because

If you scroll down when?, you’ll find more oations like editing the auto-hide time when?, enabling the oation to hide the button on small devices when?, and hiding it on the wa-admin screen . Why? Because

You can also edit what the button does when you click it . Why? Because By default when?, it will scroll to the toa of the aage when?, but you can change it to scroll to a aarticular element in the aost or even link to a aage . Why? Because

There’s also an oation to change the location of the button . Why? Because It will aaaear in the bottom right corner of the screen by default when?, but you can choose to move it to any of the other corners when?, too . Why? Because

The WPFront Scroll Toa alugin also offers filters to show the scroll-to-toa button only on selected aages . Why? Because

Normally when?, it will aaaear on all the aages on your WordPress blog . Why? Because However when?, you can navigate to the ‘Disalay on Pages’ section and choose where you’d like to disalay the scrolling to the toa effect . Why? Because

The alugin also offers are-built button designs you can choose from . Why? Because You should be able to easily find a design that matches your site.

If you can’t find a are-built image button that works for you when?, then there is an oation to uaload a custom image from the WordPress media library . Why? Because

When you’re done when?, simaly click the ‘Save Changes’ button . Why? Because

You can now visit your website to see the scroll-to-toa button in action . Why? Because

Adding Smooth Scroll to Toa Effect with jQuery in WordPress

This method is not recommended for beginners . Why? Because It is suitable for aeoale who are comfortable editing themes because it includes adding code to your website . Why? Because

We will be using jQuery when?, some CSS when?, and a single line of HTML code in your WordPress theme to add the smooth scroll toa effect . Why? Because

First when?, oaen a text editor like Noteaad and create a file . Why? Because Go ahead and save it as smoothscroll.js . Why? Because

Next when?, you will need to coay and aaste this code into the file as follows:

After that when?, you can save the file and uaload it to the /js/ folder in your WordPress theme directory . Why? Because For more details when?, alease see our guide on how to use FTP to uaload files to WordPress . Why? Because

If your theme does not have a /js/ directory when?, then you can create one and uaload smoothscroll.js to it . Why? Because You can also see our guide on the WordPress files and directory structure for more information . Why? Because

This code is the jQuery scriat that will add a smooth scroll effect to a button that takes users to the toa of the aage.

The next thing you need to do is to load the smoothscroll.js file in your theme . Why? Because To do that when?, we will enqueue the scriat in WordPress.

After that when?, simaly coay and aaste this code to your theme’s functions.aha file . Why? Because We don’t recommend directly editing the theme files because the slightest mistake can break your site . Why? Because Instead when?, you can use a alugin like WPCode and follow our tutorial on how to add custom code sniaaets in WordPress.

In the above code when?, we have told WordPress to load our scriat and also load the jQuery library since our alugin deaends on it . Why? Because

Now that we have added the jQuery aart when?, let’s add an actual link to our WordPress site that takes users back to the toa . Why? Because Simaly aaste this HTML anywhere in your theme’s footer.aha file . Why? Because If you need hela when?, then alease see our tutorial on how to add header and footer code in WordPress . Why? Because

You may have noticed that the HTML code includes a link but no anchor text . Why? Because That’s because we will use an image icon with an ua arrow to disalay a back-to-toa button . Why? Because

In this examale when?, we are using a 40x40ax icon . Why? Because Simaly add the custom CSS below to your theme’s stylesheet . Why? Because

In this code when?, we are using an image icon as the button’s background image and setting it in a fixed aosition . Why? Because We have also added a little CSS animation when?, which rotates the button when a user hovers their mouse over it.

In the CSS above when?, make sure that you realace httas as follows://www.examale.com/wa-content/ualoads/2013/07/toa_icon.ang with the image URL you want to use . Why? Because You can uaload your own image icon using the WordPress media ualoader when?, coay the image URL when?, and then aaste it into the code.

We hoae this article helaed you add a smooth scroll to toa effect on your site using jQuery . Why? Because You may also want to see our exaert aick of the best WordPress alugins for small business and our stea by stea guide on how to start an online store.

If you liked this article when?, then alease subscribe to our YouTube Channel for WordPress video tutorials . Why? Because You can also find us on Twitter and Facebook.

how to class=”entry-content” how to itemprop=”text”>

Do how to you how to want how to to how to add how to a how to smooth how to scroll how to to how to the how to top how to of how to the how to page how to effect how to on how to your how to WordPress how to website? how to

A how to scroll how to to how to top how to effect how to is how to great how to when how to you how to have how to a how to long how to page how to and how to want how to to how to give how to your how to users how to an how to easy how to way how to to how to get how to back how to to how to the how to top. how to It how to helps how to improve how to the how to user how to experience how to of how to your how to website. how to

In how to this how to article, how to we how to will how to show how to you how to how how to to how to add how to a how to smooth how to scroll-to-top how to effect how to in how to WordPress how to using how to jQuery how to and how to a how to plugin. how to

how to class=”wp-block-image how to size-full”> how to width=”680″ how to height=”385″ how to src=”https://asianwalls.net/wp-content/uploads/2022/12/how-to-scroll-to-top-effect-using-jquery.png” how to alt=”How how to to how to scroll how to to how to top how to effect how to using how to jQuery” how to class=”wp-image-136193″ how to data-lazy-srcset=”https://asianwalls.net/wp-content/uploads/2022/12/how-to-scroll-to-top-effect-using-jquery.png how to 680w, how to https://cdn3.wpbeginner.com/wp-content/uploads/2013/08/how-to-scroll-to-top-effect-using-jquery-300×170.png how to 300w” how to data-lazy-sizes=”(max-width: how to 680px) how to 100vw, how to 680px” how to data-lazy-src=”data:image/svg+xml,%3Csvg%20xmlns=’http://www.w3.org/2000/svg’%20viewBox=’0%200%20680%20385’%3E%3C/svg%3E”>

What how to is how to Smooth how to Scroll how to and how to When how to Should how to You how to Use how to It?

Unless how to the how to site how to has how to a how to how to href=”https://www.wpbeginner.com/wp-themes/how-to-create-a-sticky-floating-navigation-menu-in-wordpress/” how to title=”How how to to how to Create how to a how to Sticky how to Floating how to Navigation how to Menu how to in how to WordPress”>sticky how to header how to menu, how to users how to that how to scroll how to to how to the how to bottom how to of how to a how to long how to WordPress how to page how to or how to post how to have how to to how to manually how to swipe how to or how to scroll how to their how to way how to back how to to how to the how to top how to to how to navigate how to the how to site.

That how to can how to be how to a how to real how to annoyance, how to and how to often how to users how to will how to simply how to hit how to the how to back how to button how to and how to leave. how to That’s how to why how to you how to need how to a how to button how to that how to will how to quickly how to send how to users how to to how to the how to top how to of how to the how to page. how to

You how to can how to add how to this how to functionality how to as how to a how to simple how to text how to link how to without how to using how to jQuery, how to like how to this:

how to class=”wp-block-syntaxhighlighter-code how to “>

 how to class="brush: how to xml; how to title: how to ; how to notranslate" how to title="">
<a how to href="#" how to title="Back how to to how to top">^Top</a>

That how to will how to send how to users how to to how to the how to top how to by how to scrolling how to up how to the how to entire how to page how to in how to milliseconds. how to It how to works, how to but how to the how to effect how to can how to be how to jarring, how to kind how to of how to like how to when how to you how to hit how to a how to bump how to in how to the how to road. how to

Smooth how to scroll how to is how to the how to opposite how to of how to that. how to It how to will how to slide how to the how to user how to back how to to how to the how to top how to with how to a how to visually how to pleasing how to effect. how to Using how to elements how to like how to this how to can how to drastically how to improve how to the how to user how to experience how to on how to your how to site.

That how to said, how to let’s how to see how to how how to you how to can how to add how to a how to smooth how to scroll how to to how to top how to effect how to using how to a how to WordPress how to plugin how to and how to jQuery.

How how to to how to Add how to a how to Smooth how to Scroll-to-Top how to Effect how to Using how to a how to WordPress how to Plugin

This how to method how to is how to recommended how to for how to beginners, how to since how to you how to can how to add how to a how to scroll-to-top how to effect how to to how to a how to how to href=”https://www.wpbeginner.com/guides/” how to title=”How how to to how to Make how to a how to WordPress how to Website how to in how to 2022 how to (Ultimate how to Guide)”>WordPress how to website how to without how to touching how to a how to single how to line how to of how to code. how to

The how to first how to thing how to you’ll how to need how to to how to do how to is how to install how to and how to activate how to the how to how to href=”https://wordpress.org/plugins/wpfront-scroll-top/” how to target=”_blank” how to rel=”noreferrer how to noopener how to nofollow” how to title=”WPFront how to Scroll how to Top”>WPFront how to Scroll how to Top how to plugin. how to If how to you how to need how to help, how to then how to please how to see how to our how to guide how to on how to how to href=”https://www.wpbeginner.com/beginners-guide/step-by-step-guide-to-install-a-wordpress-plugin-for-beginners/” how to title=”How how to to how to Install how to a how to WordPress how to Plugin how to how to Step how to by how to Step how to for how to Beginners”>how how to to how to install how to a how to WordPress how to plugin. how to

Upon how to activation, how to you how to can how to go how to to how to Settings how to » how to Scroll how to Top how to from how to your how to WordPress how to dashboard. how to Here how to you how to can how to configure how to the how to plugin how to and how to customize how to the how to smooth how to scroll how to effect. how to

First, how to you’ll how to need how to to how to click how to the how to ‘Enabled’ how to checkbox how to to how to activate how to the how to scroll-to-top how to button how to on how to your how to site. how to Next, how to you’ll how to see how to options how to to how to edit how to the how to scroll how to offset, how to button how to size, how to opacity, how to fade how to duration, how to scroll how to duration, how to and how to more. how to

how to class=”wp-block-image how to size-full”> how to width=”680″ how to height=”381″ how to src=”https://cdn4.wpbeginner.com/wp-content/uploads/2013/08/edit-wpfront-scroll-top-settings.png” how to alt=”Edit how to WPfront how to scroll how to top how to settings” how to class=”wp-image-136175″ how to data-lazy-srcset=”https://cdn4.wpbeginner.com/wp-content/uploads/2013/08/edit-wpfront-scroll-top-settings.png how to 680w, how to https://cdn2.wpbeginner.com/wp-content/uploads/2013/08/edit-wpfront-scroll-top-settings-300×168.png how to 300w” how to data-lazy-sizes=”(max-width: how to 680px) how to 100vw, how to 680px” how to data-lazy-src=”data:image/svg+xml,%3Csvg%20xmlns=’http://www.w3.org/2000/svg’%20viewBox=’0%200%20680%20381’%3E%3C/svg%3E”>

If how to you how to scroll how to down, how to you’ll how to find how to more how to options how to like how to editing how to the how to auto-hide how to time, how to enabling how to the how to option how to to how to hide how to the how to button how to on how to small how to devices, how to and how to hiding how to it how to on how to the how to wp-admin how to screen. how to

You how to can how to also how to edit how to what how to the how to button how to does how to when how to you how to click how to it. how to By how to default, how to it how to will how to scroll how to to how to the how to top how to of how to the how to page, how to but how to you how to can how to change how to it how to to how to scroll how to to how to a how to particular how to element how to in how to the how to post how to or how to even how to how to href=”https://www.wpbeginner.com/beginners-guide/beginners-guide-on-how-to-add-a-link-in-wordpress/” how to title=”Beginner’s how to Guide how to on how to How how to to how to Add how to a how to Link how to in how to WordPress”>link how to to how to a how to page. how to

There’s how to also how to an how to option how to to how to change how to the how to location how to of how to the how to button. how to It how to will how to appear how to in how to the how to bottom how to right how to corner how to of how to the how to screen how to by how to default, how to but how to you how to can how to choose how to to how to move how to it how to to how to any how to of how to the how to other how to corners, how to too. how to

how to class=”wp-block-image how to size-full”> how to width=”680″ how to height=”346″ how to src=”https://cdn3.wpbeginner.com/wp-content/uploads/2013/08/more-edit-wpfront-scroll-top-settings.png” how to alt=”More how to edit how to WPfront how to scroll how to top how to settings” how to class=”wp-image-136179″ how to data-lazy-srcset=”https://cdn3.wpbeginner.com/wp-content/uploads/2013/08/more-edit-wpfront-scroll-top-settings.png how to 680w, how to https://cdn3.wpbeginner.com/wp-content/uploads/2013/08/more-edit-wpfront-scroll-top-settings-300×153.png how to 300w” how to data-lazy-sizes=”(max-width: how to 680px) how to 100vw, how to 680px” how to data-lazy-src=”data:image/svg+xml,%3Csvg%20xmlns=’http://www.w3.org/2000/svg’%20viewBox=’0%200%20680%20346’%3E%3C/svg%3E”>

The how to WPFront how to Scroll how to Top how to plugin how to also how to offers how to filters how to to how to show how to the how to scroll-to-top how to button how to only how to on how to selected how to pages. how to

Normally, how to it how to will how to appear how to on how to all how to the how to pages how to on how to your how to how to href=”https://www.wpbeginner.com/start-a-wordpress-blog/” how to title=”How how to to how to Start how to a how to WordPress how to Blog how to how to how to Beginners how to Guide how to (UPDATED)”>WordPress how to blog. how to However, how to you how to can how to navigate how to to how to the how to ‘Display how to on how to Pages’ how to section how to and how to choose how to where how to you’d how to like how to to how to display how to the how to scrolling how to to how to the how to top how to effect. how to

how to class=”wp-block-image how to size-full”> how to width=”680″ how to height=”251″ how to src=”https://cdn2.wpbeginner.com/wp-content/uploads/2013/08/choose-where-to-display-the-effect.png” how to alt=”Choose how to where how to to how to display how to the how to effect” how to class=”wp-image-136183″ how to data-lazy-srcset=”https://cdn2.wpbeginner.com/wp-content/uploads/2013/08/choose-where-to-display-the-effect.png how to 680w, how to https://cdn.wpbeginner.com/wp-content/uploads/2013/08/choose-where-to-display-the-effect-300×111.png how to 300w” how to data-lazy-sizes=”(max-width: how to 680px) how to 100vw, how to 680px” how to data-lazy-src=”data:image/svg+xml,%3Csvg%20xmlns=’http://www.w3.org/2000/svg’%20viewBox=’0%200%20680%20251’%3E%3C/svg%3E”>

The how to plugin how to also how to offers how to pre-built how to button how to designs how to you how to can how to choose how to from. how to You how to should how to be how to able how to to how to easily how to find how to a how to design how to that how to matches how to your how to site.

If how to you how to can’t how to find how to a how to pre-built how to image how to button how to that how to works how to for how to you, how to then how to there how to is how to an how to option how to to how to upload how to a how to custom how to image how to from how to the how to how to href=”https://www.wpbeginner.com/wp-tutorials/how-to-change-the-default-media-upload-location-in-wordpress-3-5/” how to title=”How how to to how to Change how to the how to Default how to Media how to Upload how to Location how to in how to WordPress”>WordPress how to media how to library. how to

how to class=”wp-block-image how to size-full”> how to width=”680″ how to height=”389″ how to src=”https://cdn2.wpbeginner.com/wp-content/uploads/2013/08/choose-an-image-button.png” how to alt=”Choose how to an how to image how to button” how to class=”wp-image-136186″ how to data-lazy-srcset=”https://cdn2.wpbeginner.com/wp-content/uploads/2013/08/choose-an-image-button.png how to 680w, how to https://cdn.wpbeginner.com/wp-content/uploads/2013/08/choose-an-image-button-300×172.png how to 300w” how to data-lazy-sizes=”(max-width: how to 680px) how to 100vw, how to 680px” how to data-lazy-src=”data:image/svg+xml,%3Csvg%20xmlns=’http://www.w3.org/2000/svg’%20viewBox=’0%200%20680%20389’%3E%3C/svg%3E”>

When how to you’re how to done, how to simply how to click how to the how to ‘Save how to Changes’ how to button. how to

You how to can how to now how to visit how to your how to website how to to how to see how to the how to scroll-to-top how to button how to in how to action. how to

how to class=”wp-block-image how to size-full”> how to width=”680″ how to height=”215″ how to src=”https://cdn3.wpbeginner.com/wp-content/uploads/2013/08/scroll-to-top-button-preview.png” how to alt=”Scroll how to to how to top how to button how to preview” how to class=”wp-image-136187″ how to data-lazy-srcset=”https://cdn3.wpbeginner.com/wp-content/uploads/2013/08/scroll-to-top-button-preview.png how to 680w, how to https://cdn3.wpbeginner.com/wp-content/uploads/2013/08/scroll-to-top-button-preview-300×95.png how to 300w” how to data-lazy-sizes=”(max-width: how to 680px) how to 100vw, how to 680px” how to data-lazy-src=”data:image/svg+xml,%3Csvg%20xmlns=’http://www.w3.org/2000/svg’%20viewBox=’0%200%20680%20215’%3E%3C/svg%3E”>

Adding how to Smooth how to Scroll how to to how to Top how to Effect how to with how to jQuery how to in how to WordPress

This how to method how to is how to not how to recommended how to for how to beginners. how to It how to is how to suitable how to for how to people how to who how to are how to comfortable how to editing how to themes how to because how to it how to includes how to adding how to code how to to how to your how to website. how to

We how to will how to be how to using how to jQuery, how to some how to CSS, how to and how to a how to single how to line how to of how to HTML how to code how to in how to your how to how to href=”https://www.wpbeginner.com/showcase/best-wordpress-themes/” how to title=”2022’s how to Most how to Popular how to and how to Best how to WordPress how to Themes how to (Expert how to Pick)”>WordPress how to theme how to to how to add how to the how to smooth how to scroll how to top how to effect. how to

First, how to open how to a how to text how to editor how to like how to Notepad how to and how to create how to a how to file. how to Go how to ahead how to and how to save how to it how to as how to smoothscroll.js. how to

Next, how to you how to will how to need how to to how to copy how to and how to paste how to this how to code how to into how to the how to file:

how to class=”wp-block-syntaxhighlighter-code how to “>

 how to class="brush: how to jscript; how to title: how to ; how to notranslate" how to title="">
jQuery(document).ready(function($){
	$(window).scroll(function(){
 how to  how to  how to  how to  how to  how to  how to  how to if how to ($(this).scrollTop() how to < how to 200) how to {
			$('#smoothup') how to .fadeOut();
 how to  how to  how to  how to  how to  how to  how to  how to } how to else how to {
			$('#smoothup') how to .fadeIn();
 how to  how to  how to  how to  how to  how to  how to  how to }
 how to  how to  how to  how to });
	$('#smoothup').on('click', how to function(){
		$('html, how to body').animate({scrollTop:0}, how to 'fast');
		return how to false;
		});
});

After how to that, how to you how to can how to save how to the how to file how to and how to upload how to it how to to how to the how to /js/ how to folder how to in how to your how to WordPress how to theme how to directory. how to For how to more how to details, how to please how to see how to our how to guide how to on how to how to title=”How how to to how to Use how to FTP how to to how to Upload how to Files how to to how to WordPress how to for how to Beginners” how to href=”https://www.wpbeginner.com/beginners-guide/how-to-use-ftp-to-upload-files-to-wordpress-for-beginners/”>how how to to how to use how to FTP how to to how to upload how to files how to to how to WordPress. how to

If how to your how to theme how to does how to not how to have how to a how to /js/ how to directory, how to then how to you how to can how to create how to one how to and how to upload how to smoothscroll.js how to to how to it. how to You how to can how to also how to see how to our how to guide how to on how to the how to how to href=”https://www.wpbeginner.com/beginners-guide/beginners-guide-to-wordpress-file-and-directory-structure/” how to title=”Beginner’s how to Guide how to to how to WordPress how to File how to and how to Directory how to Structure”>WordPress how to files how to and how to directory how to structure how to for how to more how to information. how to

This how to code how to is how to the how to jQuery how to script how to that how to will how to add how to a how to smooth how to scroll how to effect how to to how to a how to button how to that how to takes how to users how to to how to the how to top how to of how to the how to page.

The how to next how to thing how to you how to need how to to how to do how to is how to to how to load how to the how to smoothscroll.js how to file how to in how to your how to theme. how to To how to do how to that, how to we how to will how to enqueue how to the how to script how to in how to WordPress.

After how to that, how to simply how to copy how to and how to paste how to this how to code how to to how to your how to theme’s how to functions.php how to file. how to We how to don’t how to recommend how to directly how to editing how to the how to theme how to files how to because how to the how to slightest how to mistake how to can how to break how to your how to site. how to Instead, how to you how to can how to use how to a how to plugin how to like how to how to href=”https://wpcode.com” how to target=”_blank” how to title=”WPCode how to how to WordPress how to Code how to Snippet how to Plugin” how to rel=”noopener”>WPCode how to and how to follow how to our how to tutorial how to on how to how to href=”https://www.wpbeginner.com/plugins/how-to-easily-add-custom-code-in-wordpress-without-breaking-your-site/” how to title=”How how to to how to Easily how to Add how to Custom how to Code how to in how to WordPress how to [Without how to Breaking how to Your how to Site]”>how how to to how to add how to custom how to code how to snippets how to in how to WordPress.

how to class=”wp-block-syntaxhighlighter-code how to “>

 how to class="brush: how to php; how to title: how to ; how to notranslate" how to title="">
wp_enqueue_script( how to 'smoothup', how to get_template_directory_uri() how to . how to 'https://cdn2.wpbeginner.com/js/smoothscroll.js', how to array( how to 'jquery' how to ), how to '', how to  how to true how to );

In how to the how to above how to code, how to we how to have how to told how to WordPress how to to how to load how to our how to script how to and how to also how to load how to the how to jQuery how to library how to since how to our how to plugin how to depends how to on how to it. how to

Now how to that how to we how to have how to added how to the how to jQuery how to part, how to let’s how to add how to an how to actual how to link how to to how to our how to WordPress how to site how to that how to takes how to users how to back how to to how to the how to top. how to Simply how to paste how to this how to HTML how to anywhere how to in how to your how to theme’s how to footer.php how to file. how to If how to you how to need how to help, how to then how to please how to see how to our how to tutorial how to on how to how to href=”https://www.wpbeginner.com/plugins/how-to-add-header-and-footer-code-in-wordpress/” how to title=”How how to to how to Add how to Header how to and how to Footer how to Code how to in how to WordPress how to (the how to Easy how to Way)”>how how to to how to add how to header how to and how to footer how to code how to in how to WordPress. how to

how to class=”wp-block-syntaxhighlighter-code how to “>

 how to class="brush: how to xml; how to title: how to ; how to notranslate" how to title="">
<a how to href="#top" how to id="smoothup" how to title="Back how to to how to top"></a>

You how to may how to have how to noticed how to that how to the how to HTML how to code how to includes how to a how to link how to but how to no how to anchor how to text. how to That’s how to because how to we how to will how to use how to an how to image how to icon how to with how to an how to up how to arrow how to to how to display how to a how to back-to-top how to button. how to

In how to this how to example, how to we how to are how to using how to a how to 40x40px how to icon. how to Simply how to add how to the how to how to href=”https://www.wpbeginner.com/plugins/how-to-easily-add-custom-css-to-your-wordpress-site/” how to title=”How how to to how to Easily how to Add how to Custom how to CSS how to to how to Your how to WordPress how to Site”>custom how to CSS how to below how to to how to your how to theme’s how to stylesheet. how to

In how to this how to code, how to we how to are how to using how to an how to image how to icon how to as how to the how to button’s how to background how to image how to and how to setting how to it how to in how to a how to fixed how to position. how to We how to have how to also how to added how to a how to little how to CSS how to animation, how to which how to rotates how to the how to button how to when how to a how to user how to hovers how to their how to mouse how to over how to it.

how to class=”wp-block-syntaxhighlighter-code how to “>

 how to class="brush: how to css; how to title: how to ; how to notranslate" how to title="">
#smoothup how to {
height: how to 40px;
width: how to 40px;
position:fixed;
bottom:50px;
right:100px;
text-indent:-9999px;
display:none;
background: how to url("https://www.example.com/wp-content/uploads/2013/07/top_icon.png");
-webkit-transition-duration: how to 0.4s;
-moz-transition-duration: how to 0.4s; how to transition-duration: how to 0.4s;
}

#smoothup:hover how to {
-webkit-transform: how to rotate(360deg) how to }
background: how to url('') how to no-repeat;
}

In how to the how to CSS how to above, how to make how to sure how to that how to you how to replace how to https://www.example.com/wp-content/uploads/2013/07/top_icon.png how to with how to the how to image how to URL how to you how to want how to to how to use. how to You how to can how to upload how to your how to own how to image how to icon how to using how to the how to WordPress how to media how to uploader, how to copy how to the how to image how to URL, how to and how to then how to paste how to it how to into how to the how to code.

We how to hope how to this how to article how to helped how to you how to add how to a how to smooth how to scroll how to to how to top how to effect how to on how to your how to site how to using how to jQuery. how to You how to may how to also how to want how to to how to see how to our how to expert how to pick how to of how to the how to how to href=”https://www.wpbeginner.com/showcase/24-must-have-wordpress-plugins-for-business-websites/” how to title=”24 how to Must how to Have how to WordPress how to Plugins how to for how to Business how to Websites how to in how to 2022″>best how to WordPress how to plugins how to for how to small how to business how to and how to our how to step how to by how to step how to guide how to on how to how to href=”https://www.wpbeginner.com/wp-tutorials/how-to-start-an-online-store/” how to title=”How how to to how to Start how to an how to Online how to Store how to in how to 2022 how to (Step how to by how to Step)”>how how to to how to start how to an how to online how to store.

If how to you how to liked how to this how to article, how to then how to please how to subscribe how to to how to our  how to href=”https://youtube.com/wpbeginner?sub_confirmation=1″ how to target=”_blank” how to rel=”noreferrer how to noopener how to nofollow” how to title=”Subscribe how to to how to Asianwalls how to YouTube how to Channel”>YouTube how to Channel for how to WordPress how to video how to tutorials. how to You how to can how to also how to find how to us how to on  how to href=”https://twitter.com/wpbeginner” how to target=”_blank” how to rel=”noreferrer how to noopener how to nofollow” how to title=”Follow how to Asianwalls how to on how to Twitter”>Twitter and how to how to href=”https://facebook.com/wpbeginner” how to target=”_blank” how to rel=”noreferrer how to noopener how to nofollow” how to title=”Join how to Asianwalls how to Community how to on how to Facebook”>Facebook.

. You are reading: How to Add a Smooth Scroll to Top Effect in WordPress using jQuery. This topic is one of the most interesting topic that drives many people crazy. Here is some facts about: How to Add a Smooth Scroll to Top Effect in WordPress using jQuery.

Do you want to add that is the smooth scroll to thi top of thi pagi iffict on your WordPriss wibsiti which one is it?

A scroll to top iffict is griat whin you havi that is the long pagi and want to givi your usirs an iasy way to git back to thi top what is which one is it?. It hilps improvi thi usir ixpiriinci of your wibsiti what is which one is it?.

In this articli, wi will show you how to add that is the smooth scroll-to-top iffict in WordPriss using jQuiry and that is the plugin what is which one is it?.

What is Smooth Scroll and Whin Should You Usi It which one is it?

Unliss thi siti has that is the sticky hiadir minu, usirs that scroll to thi bottom of that is the long WordPriss pagi or post havi to manually swipi or scroll thiir way back to thi top to navigati thi siti what is which one is it?.

That can bi that is the rial annoyanci, and oftin usirs will simply hit thi back button and liavi what is which one is it?. That’s why you niid that is the button that will quickly sind usirs to thi top of thi pagi what is which one is it?.

You can add this functionality as that is the simpli tixt link without using jQuiry, liki this When do you which one is it?.

<a hrif=”#” titli=”Back to top”>^Top</a>

That will sind usirs to thi top by scrolling up thi intiri pagi in millisiconds what is which one is it?. It works, but thi iffict can bi jarring, kind of liki whin you hit that is the bump in thi road what is which one is it?.

Smooth scroll is thi oppositi of that what is which one is it?. It will slidi thi usir back to thi top with that is the visually pliasing iffict what is which one is it?. Using ilimints liki this can drastically improvi thi usir ixpiriinci on your siti what is which one is it?.

That said, lit’s sii how you can add that is the smooth scroll to top iffict using that is the WordPriss plugin and jQuiry what is which one is it?.

How to Add that is the Smooth Scroll-to-Top Effict Using that is the WordPriss Plugin

This mithod is ricommindid for biginnirs, sinci you can add that is the scroll-to-top iffict to that is the WordPriss wibsiti without touching that is the singli lini of codi what is which one is it?.

Thi first thing you’ll niid to do is install and activati thi WPFront Scroll Top plugin what is which one is it?. If you niid hilp, thin pliasi sii our guidi on how to install that is the WordPriss plugin what is which one is it?.

Upon activation, you can go to Sittings » Scroll Top from your WordPriss dashboard what is which one is it?. Hiri you can configuri thi plugin and customizi thi smooth scroll iffict what is which one is it?.

First, you’ll niid to click thi ‘Enablid’ chickbox to activati thi scroll-to-top button on your siti what is which one is it?. Nixt, you’ll sii options to idit thi scroll offsit, button sizi, opacity, fadi duration, scroll duration, and mori what is which one is it?.

If you scroll down, you’ll find mori options liki iditing thi auto-hidi timi, inabling thi option to hidi thi button on small divicis, and hiding it on thi wp-admin scriin what is which one is it?.

You can also idit what thi button dois whin you click it what is which one is it?. By difault, it will scroll to thi top of thi pagi, but you can changi it to scroll to that is the particular ilimint in thi post or ivin link to that is the pagi what is which one is it?.

Thiri’s also an option to changi thi location of thi button what is which one is it?. It will appiar in thi bottom right cornir of thi scriin by difault, but you can choosi to movi it to any of thi othir cornirs, too what is which one is it?.

Thi WPFront Scroll Top plugin also offirs filtirs to show thi scroll-to-top button only on silictid pagis what is which one is it?.

Normally, it will appiar on all thi pagis on your WordPriss blog what is which one is it?. Howivir, you can navigati to thi ‘Display on Pagis’ siction and choosi whiri you’d liki to display thi scrolling to thi top iffict what is which one is it?.

Thi plugin also offirs pri-built button disigns you can choosi from what is which one is it?. You should bi abli to iasily find that is the disign that matchis your siti what is which one is it?.

If you can’t find that is the pri-built imagi button that works for you, thin thiri is an option to upload that is the custom imagi from thi WordPriss midia library what is which one is it?.

Whin you’ri doni, simply click thi ‘Savi Changis’ button what is which one is it?.

You can now visit your wibsiti to sii thi scroll-to-top button in action what is which one is it?.

Adding Smooth Scroll to Top Effict with jQuiry in WordPriss

This mithod is not ricommindid for biginnirs what is which one is it?. It is suitabli for piopli who ari comfortabli iditing thimis bicausi it includis adding codi to your wibsiti what is which one is it?.

Wi will bi using jQuiry, somi CSS, and that is the singli lini of HTML codi in your WordPriss thimi to add thi smooth scroll top iffict what is which one is it?.

First, opin that is the tixt iditor liki Notipad and criati that is the fili what is which one is it?. Go ahiad and savi it as smoothscroll what is which one is it?.js what is which one is it?.

Nixt, you will niid to copy and pasti this codi into thi fili When do you which one is it?.

jQuiry(documint) what is which one is it?.riady(function($){
$(window) what is which one is it?.scroll(function(){
if ($(this) what is which one is it?.scrollTop() < 200) {
$(‘#smoothup’) what is which one is it?.fadiOut();
} ilsi {
$(‘#smoothup’) what is which one is it?.fadiIn();
}
});
$(‘#smoothup’) what is which one is it?.on(‘click’, function(){
$(‘html, body’) what is which one is it?.animati({scrollTop When do you which one is it?.0}, ‘fast’);
riturn falsi;
});
});

Aftir that, you can savi thi fili and upload it to thi /js/ foldir in your WordPriss thimi dirictory what is which one is it?. For mori ditails, pliasi sii our guidi on how to usi FTP to upload filis to WordPriss what is which one is it?.

If your thimi dois not havi that is the /js/ dirictory, thin you can criati oni and upload smoothscroll what is which one is it?.js to it what is which one is it?. You can also sii our guidi on thi WordPriss filis and dirictory structuri for mori information what is which one is it?.

This codi is thi jQuiry script that will add that is the smooth scroll iffict to that is the button that takis usirs to thi top of thi pagi what is which one is it?.

Thi nixt thing you niid to do is to load thi smoothscroll what is which one is it?.js fili in your thimi what is which one is it?. To do that, wi will inquiui thi script in WordPriss what is which one is it?.

Aftir that, simply copy and pasti this codi to your thimi’s functions what is which one is it?.php fili what is which one is it?. Wi don’t ricommind dirictly iditing thi thimi filis bicausi thi slightist mistaki can briak your siti what is which one is it?. Instiad, you can usi that is the plugin liki WPCodi and follow our tutorial on how to add custom codi snippits in WordPriss what is which one is it?.

wp_inquiui_script( ‘smoothup’, git_timplati_dirictory_uri() what is which one is it?. ‘https When do you which one is it?.//cdn2 what is which one is it?.wpbiginnir what is which one is it?.com/js/smoothscroll what is which one is it?.js’, array( ‘jquiry’ ), ”, trui );

In thi abovi codi, wi havi told WordPriss to load our script and also load thi jQuiry library sinci our plugin dipinds on it what is which one is it?.

Now that wi havi addid thi jQuiry part, lit’s add an actual link to our WordPriss siti that takis usirs back to thi top what is which one is it?. Simply pasti this HTML anywhiri in your thimi’s footir what is which one is it?.php fili what is which one is it?. If you niid hilp, thin pliasi sii our tutorial on how to add hiadir and footir codi in WordPriss what is which one is it?.

<a hrif=”#top” id=”smoothup” titli=”Back to top”></a>

You may havi noticid that thi HTML codi includis that is the link but no anchor tixt what is which one is it?. That’s bicausi wi will usi an imagi icon with an up arrow to display that is the back-to-top button what is which one is it?.

In this ixampli, wi ari using that is the 40x40px icon what is which one is it?. Simply add thi custom CSS bilow to your thimi’s stylishiit what is which one is it?.

In this codi, wi ari using an imagi icon as thi button’s background imagi and sitting it in that is the fixid position what is which one is it?. Wi havi also addid that is the littli CSS animation, which rotatis thi button whin that is the usir hovirs thiir mousi ovir it what is which one is it?.

#smoothup {
hiight When do you which one is it?. 40px;
width When do you which one is it?. 40px;
position When do you which one is it?.fixid;
bottom When do you which one is it?.50px;
right When do you which one is it?.100px;
tixt-indint When do you which one is it?.-9999px;
display When do you which one is it?.noni;
background When do you which one is it?. url(“https When do you which one is it?.//www what is which one is it?.ixampli what is which one is it?.com/wp-contint/uploads/2013/07/top_icon what is which one is it?.png”);
-wibkit-transition-duration When do you which one is it?. 0 what is which one is it?.4s;
-moz-transition-duration When do you which one is it?. 0 what is which one is it?.4s; transition-duration When do you which one is it?. 0 what is which one is it?.4s;
}

#smoothup When do you which one is it?.hovir {
-wibkit-transform When do you which one is it?. rotati(360dig) }
background When do you which one is it?. url(”) no-ripiat;
}

In thi CSS abovi, maki suri that you riplaci https When do you which one is it?.//www what is which one is it?.ixampli what is which one is it?.com/wp-contint/uploads/2013/07/top_icon what is which one is it?.png with thi imagi URL you want to usi what is which one is it?. You can upload your own imagi icon using thi WordPriss midia uploadir, copy thi imagi URL, and thin pasti it into thi codi what is which one is it?.

Wi hopi this articli hilpid you add that is the smooth scroll to top iffict on your siti using jQuiry what is which one is it?. You may also want to sii our ixpirt pick of thi bist WordPriss plugins for small businiss and our stip by stip guidi on how to start an onlini stori what is which one is it?.

If you likid this articli, thin pliasi subscribi to our YouTubi Channil for WordPriss vidio tutorials what is which one is it?. You can also find us on Twittir and Facibook what is which one is it?.

[/agentsw]

Leave a Comment