Not sure if it's just me or not, but I have noticed that [[footer_backtotop]] shortcode added in the footer via genesis_footer_creds_text filter does not work. Clicking on the "Return to top of page" footer link does not lead anywhere. My guess (being new to Genesis) is that with the release of Genesis v2.0, there have been structural changes and this shortcode has not been updated yet as it's still looking for a #wrap that does not exist.
Anyway, let's fix and in fact enhance this by making the scrolling to top action smooth using the method in this post. Another minor visual benefit is that after the go to top link is clicked, the URL of the page remains the same.
Step 1
Create a file named say, sitewide.js having the following and upload it to child theme's js
(create, if not existing) directory:
To view the full content, please sign up for the membership.
Already a member? Log in below or here.
Love this, thank you Sridhar.
[…] you are looking to add a working ‘To Top’ link in the footer, see this […]
[…] Het kan ook nog mooier met deze tip: Add a working “Return to top of page” footer link in Genesis themes […]
What are you using on your to the top?
I am sorry, you have the arrow on the sidebar that takes you to the top, which is this?
I am using Dynamic “To Top” plugin. http://wordpress.org/plugins/dynamic-to-top/. I have it mentioned in http://www.sridharkatakam.com/favorite-plugins/.
Thanks Sridhar. Super helpful!
Hi Sridhar, thanks for creating this blog post. I have sucessfully added the button and it works, but the Javascript does not. Can you tell me if I am supposed to enqueue jQuery before I add this feature? Here is a link to the project I am working on: http://151.252.1.90/~av/. I copied the script into the JS file in Genesis extender which normally works without having to add a new JS file to the child theme. Any ideas?
Thanks – worked a treat.
It worked fine when I added it to the theme functions file. Thanks for the very helpful post.
Just updated the post with the following:
“Note: All the code below goes in child theme’s functions.php.”
Hi Sridhar, thank you very much for your help with your brilliant article. Worked straight away, and then also noticed your bonus CSS, very nice touch! Hoping Sachin gets a 100 tomorrow!! 🙂
Thank you VERY much for this tutorial, I was going crazy trying to find a solution for this. Now I was wondering if it would be possible to do the same for a “Back to bottom” button. I can’t seem to find out what the new anchor for the footer is. Thanks again!
Here you go: http://www.sridharkatakam.com/set-go-bottom-link-scrolls-smoothly-wordpress/
[…] my Post titled Add a working “Return to top of page” footer link in Genesis themes, a user asked in the […]
Hi Sridar, I have used this technique a number of times now and I just wanted to say thanks again for writing this post. I have one general question about adding jQuery: I notice in this tutorial you did not enqueue jQuery to get the ‘scroll to top’ working. I have read a number of articles on using Genesis and jQuery. Some people say to use the Google CDN while others say to use jQuery that ships with WordPress. I am in my first year of web development but I would like to add elements of jQuery on my web projects. Can you give us your opinion on this subject? I have used Google CDN on a few projects, but it sometimes breaks other plugins like Nivo Slider or I have to rewrite the $ sign with ‘jQuery’. Most of what I have been doing seems like a bit of a hack. If you have any blog posts on this subject, could you add a link to them somewhere in your reply?
jQuery comes built-in with WordPress. There is no need to and in fact it is not recommended to use the one from Google CDN.
From http://wpcandy.com/teaches/how-to-load-scripts-in-wordpress-themes/#.Uq1V5mQW3tk
“Also, you’ll see I used the version of jQuery included in WordPress. So should you. You’re making a theme. Use the jQuery included with WordPress. It will always be up to date and compatible with core. It will always work. I’ve seen Otto argue with enough people about this (including me). He’s right.”
also note http://wpcandy.com/teaches/how-to-load-scripts-in-wordpress-themes/#comment-517876
Thanks Sridar. Could you answer one more question? The article you referenced is related to WordPress, as I am using The Genesis framework (which is WordPress, I know), but does all the code on that article work with genesis? Or are there any additions to the code when adding it to the Genesis Framework? That’s my last question, thanks for all your help.
Yes. The code in that article works in Genesis.
I personally just use wp_enqueue_script() instead of first using wp_register_script().
Also as we generally use a child theme, get_stylesheet_directory_uri() should be used instead of get_template_directory_uri().
For examples of using jQuery in Genesis, see http://www.sridharkatakam.com/tag/jquery/
Awesome bro. You are a star. Hopefully this will stop be breaking elements in future web projects. I will take a read today
That’s perfect article, however, I want to display a button “back to top” like on your blog. How can I do it? Thank you!
I believe Sridhar has answered that question in the comments above. It may be hard to find as there have been a lot of comments.
The back to top button he uses in his website can be downloaded here: http://wordpress.org/plugins/dynamic-to-top/ – it is very simple to set up.
You can also create a background image to the “back to top” div if you use the Genesis method. I did it on this website (you can see it below the footer) http://151.252.1.90/~av/
Hope that helps – Seb
[…] you can easily add back that ‘return-to-top’ link with another snippet from Sridhar or with plugins like ‘jQuery Smooth Scroll‘ as used here on […]
[footer_backtotop href=”#”] will work in the genesis_footer_creds_text filter
[…] inferior. Te muestro cómo hacerlo. El código lo obtuve visitando la página (en inglés) de Shridhar Katakam. Notas que apliqué a mi sitio y pude colocar dicho […]
I extended your awesome tutorial!
Inside the functions file in the add_shortcode code section I changed your code into this:
⇪
The arrow up is actually just a pasted in utf-8 code in which I removed all of the code except the arrow that showed up after I pasted it in from the keyboard symbols from my Mac, and it worked..:)
CSS that I used:
/* Code from http://www.webdesignerdepot.com/2012/11/how-to-create-a-simple-css3-tooltip/ */
.tooltip{
display: inline;
position: relative;
margin: 0 0 0 10%;
padding: 0.9em 1.5em;
color: #fff;
background: #000;
-webkit-transition: all .2s linear;
-moz-transition: all .2s linear;
-o-transition: all .2s linear;
transition: all .2s linear;
text-align:center;
-webkit-border-radius: 15px;
-moz-border-radius: 15px;
border-radius: 15px;
}
a.tooltip:hover {
color: red;
}
.tooltip:hover:after{
background: #333;
background: rgba(0,0,0,.8);
border-radius: 5px;
bottom: 45px;
color: #fff;
content: attr(title);
left: 100%;
padding: 5px 5px;
position: absolute;
z-index: 98;
width: 90px;
}
.tooltip:hover:before{
border: none;
border-color: #333 transparent;
border-width: 6px 6px 6px0 6px;
bottom: 20px;
content: "";
left: 50%;
position: absolute;
z-index: 99;
}
Perhaps you could just add it into your tutorial?
The html functions code was stripped so I am pasting without bracket start and end:
a href=”#” class=”tooltip” title=”Back to top”>⇪</a
Thank you, worked perfectly!
I can’t thank you enough for this detailed information. It has helped me immensely!
Very easy. Worked perfect. The hard part was finding this solution. Grrrrrrr!
Wow! I came to fix the “Return to top” problem of Genesis but I got a better solution. Thanks for mentioning the plugin Dynamic “To Top” Plugin.’
Cheers! 🙂
[…] http://sridharkatakam.com/add-working-return-top-page-footer-link-genesis-themes/ […]