描述
WPWing Sticky Block is a Gutenberg container block that sticks to the top of the page once the visitor scrolls past it. Drop any blocks inside — a navigation menu, a call-to-action, a contact button, a sidebar widget — and they will follow the reader down the page.
Unlike CSS position: sticky (which only works within its parent scroll container), WPWing Sticky Block uses position: fixed with intelligent scroll detection, so it works reliably in any layout.
Key Features
- Multiple sticky blocks per page — place as many sticky blocks as you need, each with its own settings.
- Container block — nest any Gutenberg blocks inside: navigation, buttons, headings, images, widgets.
- Top offset — set how many pixels of space to leave between the sticky block and the top of the viewport.
- Admin toolbar aware — automatically shifts down for logged-in users who have the WordPress admin bar visible.
- Z-index control — fine-tune stacking order so the sticky block always sits above (or below) other elements.
- Scroll direction mode — choose “Always sticky” or “Only while scrolling up” (the pattern used by modern sticky headers that appear on the way back up).
- Stop before an element — un-stick the block before it overlaps a footer or another landmark, using a CSS selector (e.g.
#footer). - Disable on mobile — turn off sticky behaviour below a configurable viewport breakpoint (default 768 px).
- Sticky-state background color — set a background color that only appears while the block is stuck, e.g. a solid white behind a transparent nav.
- Sticky-state shadow — add a drop shadow (Small / Medium / Large) that appears only when the block is in sticky position.
- Sticky-state top padding — add extra breathing room above the content when the block is stuck.
- Accessibility — set an
aria-labelon the sticky wrapper to give screen reader users useful context. - Zero dependencies — no jQuery. The frontend script is plain JavaScript, under 2 KB minified.
How to use
- In the block editor, search for Sticky Block and insert it anywhere on your page.
- Add blocks inside it — a Navigation block, a Button, a Group, anything you like.
- Open the block settings panel on the right and adjust offset, z-index, scroll behaviour, and sticky-state styles.
- Preview your page and scroll — the block will stick to the top.
屏幕截图
区块
该插件提供了 1 个区块.
- WPWing Sticky Block A sticky container block. Drop any blocks inside and they will follow the reader as they scroll — with controls for offset, z-index, scroll direction, mobile breakpoint, and sticky-state styles.
安装
Automatic installation
- Go to Plugins Add New in your WordPress admin.
- Search for WPWing Sticky Block.
- Click Install Now, then Activate.
Manual installation
- Download the plugin ZIP from WordPress.org.
- Go to Plugins Add New Upload Plugin.
- Upload the ZIP and activate.
常见问题
-
Can I add more than one sticky block on a page?
-
Yes — v2.0.0 fully supports multiple sticky blocks on the same page. Each block has its own independent settings and scroll listener.
-
Does it work with the full-site editor (FSE)?
-
Yes. The block works in both the classic page/post editor and the full-site editor (Site Editor) in WordPress 5.9+.
-
Why does my sticky block not work inside a column or group?
-
If a parent element has
overflow: hiddenoroverflow: clipset,position: fixedwill be clipped to that container and may not behave as expected. Remove the overflow restriction on the parent, or move the sticky block outside the constrained container. -
Can I disable sticky behaviour on phones?
-
Yes. Open the Responsive panel in the block settings and enable “Disable sticky on mobile”. You can also adjust the breakpoint (default: 768 px).
-
Open the Behavior panel and enter a CSS selector in the “Stop before element” field — for example
#footeror.site-footer. The block will un-stick before its bottom reaches that element. -
Will it conflict with my theme’s sticky header?
-
It should not conflict, but if both your theme and the plugin apply
position: fixedto overlapping elements, adjust the Z-index setting in the block sidebar to control which element sits on top.
评价
此插件暂无评价。
贡献者及开发者
更新日志
2.0.0
- New: multiple sticky blocks supported per page (removed the single-block limitation).
- New: “Only while scrolling up” scroll direction mode.
- New: Stop-before-element setting — un-stick before a chosen element (e.g. footer).
- New: Disable-on-mobile toggle with configurable breakpoint.
- New: Sticky-state background color (shown only when the block is stuck).
- New: Sticky-state shadow presets (Small / Medium / Large).
- New: Sticky-state top-padding control.
- New: ARIA label control for accessibility.
- Improvement: Rewrote frontend script in vanilla JavaScript — no jQuery dependency.
- Improvement: Scroll handler uses requestAnimationFrame for smooth, jank-free performance.
- Improvement: Upgraded to Gutenberg Block API v3.
- Improvement: Frontend script registered via block.json viewScript — loads only on pages that contain the block.
- Fix: Editor border style now correctly targets the block wrapper class.
- Fix: adminBarHeight variable scope (was implicit global).
- Fix: stopBefore check now evaluated before sticky is applied, preventing a one-frame flicker.
- Fix: Trigger position (divTop) and block width recalculated on viewport resize to handle layout reflows.
- Fix: Minimum WordPress version corrected to 5.8 (was incorrectly listed as 4.8 in readme).
- Tested up to WordPress 7.0.
1.0.1
- Minor fixes.
1.0.0
- Initial release.




