How to create a ‘Back To Top’ hyperlink in WordPress – There are times when you may want to provide readers with an easy way to get back to the top of a post or page (especially if it’s a long one) and this short tutorial shows exactly how to do it in a couple of minutes.
The first step is to create an anchor link for the whole page that will work when all ‘Back To Top’ destination links are clicked within the body of the page. As we’re working with WordPress this is very easy to do.
Before you do that check to make sure the ‘Scripts’ box is active on the page you’re working on. Go into ‘Edit’ mode for that page (or add a new page which will automatically take you into edit mode) and click on the ‘Screen Options’ tab at the top right of the browser to make sure the ‘Scripts’ box is activated.
Scroll down the edit screen to locate the ‘Scripts’ box and add this code:
This is a page-specific anchor link and will work for all targeted destination links from anywhere within the page.
Select the ‘Text’ tab on the top-right of the content edit box. This opens up the page in HTML mode as opposed to Visual mode. You’ll notice the tool bar also changes when you do this. Now add this code at the points within the page that you want readers to have the opportunity to return back to the top:
<a href="#top">Back To Top</a>
That’s it, you’re done. A lean and straight forward way to add visitor-friendly functionality to your posts and pages.