Get inside access to design tips from a pro! Subscribe to Design to Dollars

GeneratePress

How to Enable & Customize a Back to Top Button in GeneratePress

Adam Wright

by Adam Wright

If you’re building a webpage and find that the length of the page is too long, adding a floating “Back to Top” button can help improve navigation. In this guide, I’ll show you how to insert and customize this feature using GeneratePress.

Step 1: Enable the Back to Top Button in GeneratePress

The beauty of GeneratePress is that it includes a “Back to Top” button feature built into the theme. Here’s how to enable it:

  1. Go to your WordPress dashboard.
  2. Navigate to Appearance > Customize.
  3. In the Customizer, go to Layout > Footer.
  4. Scroll down until you see the “Back to Top Button” option and enable it.

Now, when you scroll down your page, you’ll see the “Back to Top” button appear, allowing users to easily jump back to the top.

Step 2: Customize the Back to Top Button with CSS

If you want to adjust the position or style of the “Back to Top” button, you can do so by adding some custom CSS.

  1. Go to Appearance > Customize > Additional CSS.
  2. Add the following CSS to adjust the position of the button:
.generate-back-to-top {
bottom: 100px;
right: 100px;
}

This code moves the button 100 pixels up from the bottom and 100 pixels in from the right side of the screen. You can adjust the values to suit your needs.

Step 3: Customize Colors in GeneratePress Premium

If you’re using GeneratePress Premium, you can easily customize the colors of the “Back to Top” button:

  1. Go to Appearance > Customize > Colors.
  2. Scroll down to the “Back to Top” section.
  3. Adjust the button’s background color, hover color, and text color as needed.

Step 4: Adjust the Button Size and Shape with CSS

You can also change the size and shape of the button:

.generate-back-to-top {
width: 75px;
height: 75px;
line-height: 75px;
border-radius: 500px;
}

This code makes the button larger (75×75 pixels) and transforms it into a circle.

Step 5: Customize Scroll Speed and Appearance Timing with PHP

For further customization, you can control how quickly the page scrolls back to the top and how far users need to scroll before the button appears.

  1. Go to Appearance > Theme File Editor.
  2. In the functions.php file, add the following code to adjust the scroll speed (in milliseconds):
add_filter( 'generate_back_to_top_scroll_speed', function() {
return 400; // Adjust to your desired speed
} );
  1. To adjust how far users need to scroll before the button appears, add this code:
add_filter( 'generate_back_to_top_display_distance', function() {
return 600; // Adjust to your desired distance in pixels
} );

Conclusion

The “Back to Top” feature in GeneratePress is simple to set up and customize. Whether you’re using the free version or GeneratePress Premium, you can easily add, style, and tweak this feature to enhance your website’s usability.

Subscribe

Follow My YouTube Channel for More Tutorials

Subscribe to Channel
Adam Wright

About the Author

Adam Wright

Adam is a California native, now living in Middle Tennessee. A long-time creative at heart, his passion for design and growing his small business, AWD, is always evident. When he's not writing code or sketching logos, he enjoys spending time with family, playing basketball, or watching just about any motorsports. Find him on LinkedIn.