- WordPress Tutorials
- Artisteer Tips
- Add Button Class to Widget
- Add Style to Text Widget
- Add a Sidebar in the Header
- Create Custom Post Header
- Create Unique Page Template
- Create Secondary Menu
- Create Styled Donate Button
- Create Widget Style – Part 1
- Create Widget Style – Part 2
- Hide Category Titles
- Styling Featured Image
- Styling Sheet Borders
- Using Theme Options
- Design Tips and Tricks
- Recent Projects
How to Add a “Back to Top” Button to WordPress
Adding a scrolling “Back to Top” button is a very nice feature for your blog so that people don’t have to keep scrolling to get back to the top of the page. I have already posted on how to do this for your BlogSpot blogs, and you can view that post on Blogger Scrapbook by clicking here.
Adding this button to WordPress takes a few more steps, but is still relatively easy. Now, I got the basic information from a site called instantShift, but they don’t have all of the information you need to actually add a button yourself. But, not to fear, I have been working and tweaking until I figured out exactly what you need to do in the simplest way! So, here goes!
- First of all, create and upload an image you want to use to your WordPress ftp, and save the url to it’s location.
- Secondly, log into your dashboard and click on Editor, then Header.php.
- Look for the following code:
</head>
<body> - If the body element already has an id, copy that id name, but if it does not, give it an id by changing it to the following and save your template:
<body id=”top”> - Now, go to your Footer.php and find the following code
<p> class=”art-page-footer”></p>
</div> - Directly after that code, add this code:
<div>
<a style=”display:scroll;position:fixed;bottom:10px;right:10px;” href=”#top“><img
src=”THE URL TO YOUR IMAGE HERE”/></a>
</div> - Change the URL to your actual image url, and you can change the position on the screen by changing the red elements above.
- Make sure, that if your Header.php already had an id associated with the body, that you replace “#top” to that id instead making sure to keep the # and quotation marks.
- Save your template, and you are all done!
- If you also want to add a text link to the bottom of your posts, all you need to do is add the code below to the bottom of each post that you write (just make sure that you are in HTML mode and not Visual):
<a href=”#top”>Back to Top</a>
I just did this for my own site, and it works great in IE, Firefox, and Safari. Hint: You can use this same trick to add buttons to your footer that link to your RSS feed, or other items. Simply change the “#top” to the http address where you want the image to link to, and of course, you’ll need to add the correct image and image url as well.
Please leave a comment if this was helpful or if you have any questions, and feel free to contact me if you are interested in any customized graphics or buttons. I do have some free pre-made and hosted back to top buttons available on my Blogger Scrapbook site.
© 2009 – 2010, Sarah Roberts – Reflecting the Designer. All rights reserved.
10 Responses to How to Add a “Back to Top” Button to WordPress
-
not working dude !!
can u explain in detail plz mail me:
plzz
thnx in advance -
ya it was the problem of direction of the quotation marks
….it worked gr8 and thnx for the reply !!
Thn i downloaded the plugin [SMOOTH SCROLLING LINKS IN WORDPRESS [SSL]]
from here:http://www.thechetan.com/smoothscrolllinks/#header
u can visit my blog….i have just started updating it !!VERY THNX FOR THE DIRECT REPLY !!
-
and 1 more thing your site looks gr8…i’ll subscribe to it !!
-
thanks for the info
really helpful…i can’t get adsense ads…can u help me? please -
I have been using this and forgot where I originally found it. I LOVE that it is so much cleaner than typical buttons or links all over a page just to return to the top.
I may have one simplification. I use ‘ href=”#” ‘ and I do not have to rename, edit or use the ‘ body id=”top” ‘.
CODE:
CSS:
.float-scroll{
display:scroll;
position:fixed;
bottom:5px;
right:5px;}For my purposes, I have also placed the code in the main body of my page text so I can use it on a page by page condition (some pages are so small they won’t scroll much if any). Hope this is useful.




