Archived topic
Back To Top Button in Sidebar
5 replies · Started by Paul on June 27, 2022
Hi there! You have all been so so amazing with help and I hope this is a easy fix!
I know, this is not a generatepress site, but see how they have the back to top button in their sidebar - https://www.dlxsf.com/
Is it possible for me to put my back to top button in my sidebar?
Thank you!
Paul
Hi Paul,
The easiest way would be adding a button with #top as its link to the sidebar, you can use a block element for that.
Add smooth-scroll to the button's additional CSS class(es) field.
Enable the smooth scroll function at customizer > general.
Or
You can try this PHP snippet:
add_action('wp', function() {
remove_action( 'generate_after_footer', 'generate_back_to_top');
add_action('generate_after_right_sidebar_content', 'generate_back_to_top');
});
Then add CSS to override the button's original CSS:
.sidebar a.generate-back-to-top {
position: relative;
bottom: unset;
right: unset;
display: block;
opacity: 1 !important;
visibility: visible !important;
margin-right: auto;
margin-left: auto;
}
If you want to style the button, you can add more CSS to this one.
It works!!!!!! Thank you so so much! Thank you!
You are welcome :)
Glad it works!
This is awesome, exactly what I´m looking for and so easy to use. Thanks for this nice solution and the significant hint to just use "#top" at a button. I just build a mobile footer bar with some contact elements and also the back-to-top button to save some space on smaller screens. I love this support forum! Thank you Ying and also Paul for the question.
Hi Maik,
Glad the solution works for you :)