Plugin Documentation
WDD Back To Top
A transparent, icon-only navigation plugin for WordPress. Scroll visitors back to the top — or straight to the bottom — with two fully independent, pixel-precise buttons.
Getting Started
Overview
WDD Back To Top places a fixed arrow button on every page of your site. When a visitor scrolls down past a configurable distance, the button fades in and smoothly scrolls them back to the top when clicked. Everything — colour, size, position, speed — is controlled from a single settings page in the WordPress admin.
Version 2.0.0 introduced an optional Scroll to Bottom button: a mirrored counterpart that appears at the top of the scroll range and guides visitors to the bottom of the page. Both buttons are completely independent and have no shared settings.
⬆ Back To Top
- Always active — no enable toggle needed
- Fades in after a configurable scroll threshold
- Smooth animated scroll to the top of the page
- Full appearance and position control
- Mobile visibility toggle
- Keyboard-accessible (Tab + Enter)
⬇ Scroll To Bottom
- Optional — off by default, zero footprint
- Shows while there is still content below
- Hides when within a threshold of the bottom
- Full independent appearance and position control
- Defaults to the opposite side from BTT
- Keyboard-accessible (Tab + Enter)
Getting Started
Installation
-
1Upload the plugin folder
Copy the
wdd-back-to-topfolder into your/wp-content/plugins/directory via FTP, SFTP, or your host's file manager. -
2Activate the plugin
Go to Plugins → Installed Plugins in your WordPress admin and click Activate next to WDD Back To Top.
-
3Open the settings page
Navigate to Settings → WDD Back To Top. The Back to Top button is active immediately. Customise both buttons and save.
SCRIPT_DEBUG set to true in wp-config.php, the unminified source files load instead — useful when debugging.
Features
Back To Top
The Back to Top button is always enabled. It hides itself with opacity: 0 and
pointer-events: none until the visitor scrolls past the configured threshold,
then fades in with a subtle upward slide. Clicking — or pressing Enter when focused — starts
a smooth jQuery scroll animation back to scrollTop: 0.
Appearance
The arrow is a pure SVG drawn with two paths — a vertical stem and a chevron head. You control the stroke colour, height, line weight, and whether a drop shadow renders beneath it via filter: drop-shadow().
Position
Choose left or right side. Set the distance from the bottom of the viewport and the distance from the chosen edge — both in pixels. The opposite edge is always set to auto so no layout conflict occurs.
Behaviour
Show After Scrolling is the number of pixels the visitor must scroll
before the button appears. Scroll Speed is the jQuery animation duration
in milliseconds. Both are applied via wp_localize_script() so they're always
in sync with your saved settings.
requestAnimationFrame, capping updates at ~60 fps regardless of how fast the visitor scrolls. This keeps CPU usage flat even on very long pages.
Features
Scroll To Bottom
The Scroll to Bottom button is disabled by default. When disabled, no HTML is rendered, no CSS is output, and the JavaScript skips all STB logic — it has zero front-end cost until you turn it on.
Once enabled, it works on the inverse logic of the Back to Top button: it shows when there is still scrollable content below and hides when the remaining scroll distance drops below the configured threshold.
Visibility logic
// Remaining distance to the bottom of the page function remainingScroll() { return $( document ).height() - $( window ).height() - $( window ).scrollTop(); } // STB is visible while more than STB_THRESHOLD px remain if ( remainingScroll() > STB_THRESHOLD ) { $stb.addClass( 'wdd-stb-visible' ); } else { $stb.removeClass( 'wdd-stb-visible' ); }
Default placement
The STB button defaults to the left side of the screen, keeping it on the opposite side from the BTT button (which defaults to the right). This means both buttons coexist visually without overlapping straight out of the box. You can move either button to any side with any offset.
Reference
All Settings
Every setting is stored in a single WordPress option (wdd_btt_options) as a serialised array. All values are sanitised and range-clamped on save.
⬆ Back To Top
stroke-width value — heavier numbers give a bolder arrow. 1–8filter: drop-shadow(0 2px 8px rgba(0,0,0,0.25)) to the SVG so it reads on any background.auto.bottom CSS value for the fixed button. 0–300left or right CSS value for the fixed button. 0–200@media(max-width:767px){display:none!important} inline.⬇ Scroll To Bottom
stroke-width for the STB arrow. Independent of the BTT setting. 1–8drop-shadow filter independently to the STB arrow.bottom CSS value for the STB button. 0–300left or right offset from the chosen screen edge. 0–200@media rule hiding the STB button on screens ≤ 767 px.Reference
Compatibility
WDD Back To Top is tested against the most widely-used caching and optimisation plugins. The table below summarises what was verified in the v2.0.1 test suite.
| Plugin / Environment | Version tested | Status | Notes |
|---|---|---|---|
| WP Rocket | 3.16 | ✓ Compatible | Script handle excluded via rocket_excluded_handles filter. Defer and delay do not apply. |
| LiteSpeed Cache | 6.4 | ✓ Compatible | Full-page cache tested; buttons appear correctly after serving from cache. |
| W3 Total Cache | 2.7 | ✓ Compatible | JS and CSS minify options enabled; no conflicts observed. |
| Autoptimize | 3.1 | ✓ Compatible | Script and style aggregation tested; inline styles preserved correctly. |
| Elementor | 3.x | ✓ Compatible | Buttons render correctly on Elementor-built pages. No Elementor dependency. |
| WordPress Core jQuery | Bundled | ✓ Required | The plugin uses the jQuery version bundled with WordPress. Sites that dequeue jQuery will lose scroll animation (button still renders). |
| PHP | 7.4, 8.1, 8.2 | ✓ Compatible | No deprecated syntax; tested clean on all three versions with WP_DEBUG on. |
Reference
Developer Notes
Option key
All settings are stored under a single WordPress option. Retrieve it in code like this:
$opts = get_option( 'wdd_btt_options', array() ); // Or use the static helper which merges defaults automatically: $opts = WDD_BTT_Settings::get();
Minified asset switching
The plugin checks SCRIPT_DEBUG at runtime to decide which file to serve:
// Returns '.min' in production, '' when SCRIPT_DEBUG is true function wdd_btt_asset_suffix() { return ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; }
WP Rocket exclusion
The script handle is excluded automatically. You do not need to add it manually in WP Rocket's settings:
add_filter( 'rocket_excluded_handles', function( $handles ) { $handles[] = 'wdd-back-to-top'; return $handles; } );
Dynamic CSS delivery
Position, colour, size, and shadow values are not hardcoded in the stylesheet. They are injected
as an inline <style> block by PHP via wp_add_inline_style(),
attached to the plugin's CSS handle. This avoids cache-busting issues when settings change
and keeps the static CSS files purely structural.
Resetting to defaults
The Reset Defaults button in the admin generates a nonce-protected GET request. You can also reset programmatically:
delete_option( 'wdd_btt_options' ); // The plugin will fall back to WDD_BTT_Settings::defaults() on next load.
About
Changelog
-
Fix
Admin section banner backgrounds for Back to Top and Scroll to Bottom were rendering white instead of their dark gradients. Root cause:
.wdd-btt-card { background: #fff }and the banner modifier classes share equal CSS specificity. Fixed by adding!importantto both gradient declarations and regenerating the minified admin CSS.
- New Optional Scroll to Bottom button — fully independent from Back to Top with its own complete settings set.
- New Dual live preview in the admin sidebar — both arrows update in real time as you change settings.
- New Visual section banners in the settings page separating Back to Top and Scroll to Bottom groups.
- Improved Nonce verification added to the Reset Defaults action (was missing in v1.0.0).
- Improved
requestAnimationFramethrottle on the scroll event handler — ~60 fps max instead of every pixel. - Improved Minified assets (
*.min.css/*.min.js) auto-served in production viaSCRIPT_DEBUGcheck. - Improved WP Rocket
rocket_excluded_handlesfilter added to prevent defer/delay conflicts. - Improved Named functions replace all anonymous
add_action()closures. - Improved
aria-hidden="true"andfocusable="false"added to all SVG elements. - Fixed Admin CSS dependency now correctly lists
wp-color-picker.
- New Back to Top button with configurable colour, size, stroke, shadow, position, threshold, speed, and mobile toggle.
- New Admin settings page with live preview, colour picker, and Reset Defaults action.
About
FAQ
Does this plugin work without a page builder like Elementor?
Yes — it works with any WordPress theme or page builder. There is no Elementor dependency whatsoever. It hooks into wp_footer to render the button HTML, which runs regardless of how the page content is built.
How do I enable the Scroll to Bottom button?
Go to Settings → WDD Back To Top and scroll to the Scroll To Bottom section. Toggle Enable Scroll to Bottom Button on, configure it as you like, and click Save Settings.
The button is disabled by default and has absolutely no front-end impact until you enable it — no HTML is output, no CSS is injected, and the JavaScript skips all STB logic.
Can both buttons be on the same side of the screen?
They can, but they will visually overlap if they have the same bottom offset. To stack them on the same side, use different bottom offsets — for example, BTT at 40 px and STB at 160 px.
The default configuration places BTT on the right and STB on the left, so they coexist without any adjustment needed.
Is the plugin compatible with WP Rocket?
Yes. The plugin registers a rocket_excluded_handles filter automatically, so WP Rocket will not defer, delay, or minify the plugin's script. You do not need to configure anything in WP Rocket's settings.
The Scroll to Bottom button shows on pages that aren't scrollable. Is that a bug?
No — the visibility logic checks the remaining scroll distance against your configured threshold. If the page content is shorter than the viewport plus the threshold, the button will correctly stay hidden. If the button appears briefly on load and then hides, consider lowering the Hide Within…of Bottom threshold value.
How do I reset all settings back to the defaults?
Click the Reset Defaults button at the bottom of the settings page. You will be asked to confirm. The action is protected by a WordPress nonce to prevent CSRF attacks.
Alternatively, you can delete the option directly: delete_option( 'wdd_btt_options' );
Where are the minified files and when are they used?
Minified files sit alongside the source files in assets/css/ and assets/js/ with a .min suffix. The plugin checks SCRIPT_DEBUG at runtime: if it is false (production), the .min files load. If it is true (development), the full source files load instead.
The arrow appears in front of/behind a sticky header or cookie banner. Can I change the z-index?
Both buttons use z-index: 99999. If another element on your site uses a higher z-index, you can override this with a simple CSS rule in your theme's stylesheet or in the WordPress Customizer's Additional CSS panel:
#wdd-back-to-top, #wdd-scroll-to-bottom { z-index: 999999; }