Plugins Plugin hub Backup SEO Caching Security Forms WooCommerce Images Best backup plugins
Hosting Hosting directory Shared hosting Managed WordPress Cloud hosting VPS hosting By reader location Hosting finder
Themes & builders Compare Rank Math vs Yoast
Tools All tools Hosting finder Plugin stack builder Cost calculator Salt generator Theme detector Who is hosting this? Speed test Headline analyzer robots.txt generator Redirect generator Uptime calculator Blog name generator
Blog Best backup plugins Deals
Guides All guides Speed up WordPress Choose hosting Back up WordPress
How we test

Setup & site building · Guide

How to Make a Sticky Header in WordPress

How to Make a Sticky Header in WordPress

Short answer

To make a sticky header in WordPress, wrap the header template part in a Group block at the top level of a block theme template, then set that Group to Sticky in the Position panel. Give the Group a background color and save the template. In a classic theme, use the theme sticky header setting, or add position: sticky with top: 0 in CSS.

Key takeaways

  • WordPress 6.2 added sticky positioning for Group blocks, with no code needed.
  • Wrap the whole header template part in a Group block; a block inside the header sticks only within the header.
  • Core outputs position: sticky, top: 0px and a z-index of 10 for sticky Group blocks.
  • GeneratePress sticky navigation needs the GP Premium Menu Plus module.
  • A sticky header without a background color lets page text show through as it scrolls.

What is a sticky header in WordPress?

A sticky header stays visible at the top of the screen while the rest of the page scrolls underneath it.

The header holds the logo and the menu, so a sticky header keeps navigation within reach on a long page. Readers can jump to another page without scrolling back to the top.

The effect comes from CSS position: sticky, which sticks an element to its nearest scrolling parent. Make WordPress Core states that the sticky position follows the CSS behavior for position: sticky, which sets an element to stick to its immediate parent when the user scrolls down the page.

A sticky header is not the same as a fixed header. A fixed header is removed from the page flow and always sits on top.

A sticky header scrolls normally until it reaches the top, then sticks there. That small difference matters: a sticky header needs a parent tall enough to scroll through, or it has nothing to stick to.

How do you make a sticky header in a block theme?

Wrap the header template part in a Group block at the top level of the template, then set that Group block to Sticky in the Position panel.

WordPress has offered this without code since version 6.2. Make WordPress Core states that WordPress 6.2 adds position block support, beginning with sticky positioning, with the Group block opted in by default.

Follow these steps:

  1. Go to Appearance, then Editor, then Templates, and open a template such as Single Posts.
  2. Click the header and confirm the Header template part is selected, not a block inside it. List View helps here.
  3. Open the block options menu (the three dots) and select Group. The header is now wrapped in a Group block.
  4. In the block settings on the right, find the Position panel and change it from Default to Sticky.
  5. Give the Group a background color, the same color as your page background.
  6. Click Save.

The background color matters. Without it, the page content shows through the header as it scrolls underneath, and the text overlaps. A solid background keeps the header readable.

Repeat the steps for each template you want the header to stick on. The change applies to one template at a time, so Single Posts, Pages and Blog Home each need the same treatment. The guide to editing the header in a block theme shows where the header template part lives.

How do you make a sticky header with a classic theme?

Check your theme settings first: many classic themes include a sticky header or sticky navigation toggle that needs no code.

In GeneratePress, the setting lives under Appearance, then Customize, then Layout, then Sticky Navigation. Learn GeneratePress states that you set Sticky Navigation to Mobile only, Desktop only or On to make the primary navigation stick to the top of the screen.

GeneratePress needs its premium Menu Plus module for this setting. The same Learn GeneratePress page lists “Requires GP Premium, Menu Plus module” at the top, and the options include a Fade or Slide transition, a “Hide when scrolling down” choice, and a separate sticky navigation logo.

Other classic themes put the toggle in different places. Check Customize, then Header, or your theme options panel, before you install a plugin. A theme setting is the best route when it exists, since the theme author built it against the theme header markup.

MethodCode neededBest for
Theme settingNoClassic themes with a sticky toggle
Group block StickyNoBlock themes on WordPress 6.2 or newer
CSS position: stickyYes, a few linesClassic themes with no setting
Sticky header pluginNo, needs a CSS selectorHeaders that must shrink or hide on scroll

How do you make a header sticky with CSS?

Add position: sticky and top: 0 to the header element, give it a background color, and set a z-index so it sits above the page content.

Use this route when your theme has no setting and you run a classic theme or a custom header. Add the CSS in Customize, then Additional CSS, or in a child theme stylesheet:

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: #fff;
}

WordPress core itself outputs position: sticky, a top position of 0px, and a hard-coded z-index value of 10 for sticky Group blocks, as stated by Make WordPress Core. Matching those values keeps your custom CSS in line with what core does.

Find the right selector first. Right-click the header in your browser, choose Inspect, and read the class or ID on the header element, such as .site-header or #masthead. A selector that matches nothing changes nothing, and a selector that is too broad can stick the wrong element.

MDN documents the position property, including the rule that a sticky element sticks within its parent. That rule explains the most common CSS failure: a header inside a short parent stops sticking as soon as the parent scrolls away.

What if the Position panel is missing?

The panel appears only for Group blocks at the root of the template, and only when the theme allows sticky positioning.

Two conditions must hold, as described by Make WordPress Core:

  • The block must be a Group block at the root of the document. In WordPress 6.2, the positioning controls show only for Group blocks at the root, so a block nested inside the header does not offer the option.
  • The theme must opt in. Themes using the appearanceTools feature in theme.json allow the Group block to be set to sticky. Other themes need settings.position.sticky set to true in theme.json. Developer.WordPress.org states that settings.appearanceTools enables several design settings at once, including position.sticky.

If your theme is a default block theme such as Twenty Twenty-Five, the panel should appear. The guide to using theme.json explains where the settings file lives and how the appearance tools setting works.

If the theme does not allow it, the CSS route above still works. Add the rule to the header selector and check the result on the live site.

Why does a sticky header fail?

The most common cause is making a block inside the header sticky instead of the block around it.

A sticky block sticks only within its parent. A Group inside the header stops sticking as soon as the header itself scrolls out of view, which happens at once.

Make WordPress Core states that to create a sticky header in a site template, you wrap a Header template part in a Group block and set that Group block to sticky.

Check these causes in order:

  • You set Sticky on a block inside the header. Move the setting to the Group that wraps the whole header template part.
  • The header has no background color. The page text shows through and the header looks broken, even though it sticks.
  • A parent element has overflow: hidden. That clips the sticky element and stops it from sticking at all.
  • You are logged in and the admin bar covers the header. WordPress adds an offset for the logged-in admin bar, as stated by Make WordPress Core, so check the result while logged out too.

Test in a private window after every change. The admin view and the visitor view differ, and the private window shows the visitor view.

Should the header hide when scrolling down?

Hide the header on scroll down when screen space matters, such as on phones, and keep it always visible when navigation is the main job of the page.

GeneratePress offers this as a setting. Learn GeneratePress states that “Hide when scrolling down” hides the navigation while scrolling down and returns it when scrolling up, which saves space, especially on phones.

A header that hides on scroll down gives readers more room to read. A header that stays visible keeps the menu one click away. There is no right answer for every site: a shop with many categories gains from a visible menu, while a long article gains from the extra space.

The menu item height setting in GeneratePress runs from 20 to 150 px, as listed on the same Learn GeneratePress page. A lower value while sticky makes the header shrink as you scroll, which is a middle path between hiding it and keeping it full size.

How do you check that a sticky header works?

Scroll a long page slowly on desktop and on a phone, while logged out, and watch the header at the top, middle and bottom of the page.

Run these checks after setup:

  1. Open a long post in a private window and scroll down slowly. The header should stop at the top and stay there.
  2. Scroll back up and confirm the header returns to its normal place.
  3. Open the same page on a phone and repeat the scroll. A header that works on desktop can cover half a phone screen.
  4. Click a menu link from the sticky header and confirm the link works while the header is stuck.
  5. Scroll to a page anchor, such as a section link, and confirm the sticky header does not cover the heading.

A header that covers anchored headings is a known side effect of sticky headers. Leave extra top spacing on anchored sections, or accept that the first line sits under the header.

What mistakes should you avoid?

Do not make the header too tall, do not skip the background color, and do not add a sticky header plugin when your theme already offers one.

  • Do not build a tall sticky header. A header with a logo, a menu and a top bar can eat a third of a phone screen when stuck.
  • Do not forget the background color. Transparent sticky headers are the most common visual bug.
  • Do not install two sticky header plugins. They both try to control the same element, and the result is a header that jumps.
  • Do not make the header sticky on every template without checking each one. A template with a different header layout can break in a way the home page does not show.
  • Do not assume the block theme route works in a classic theme. The guide comparing block themes and classic themes explains which editing route your theme uses, so you pick the right method first.

Start with the theme setting, then the Group block route, then CSS. A sticky header should feel quiet: visitors notice the menu is always there, and never notice the header itself.

Frequently asked questions

Why is my sticky header not working?

The most common cause is setting Sticky on a block inside the header instead of the Group that wraps the whole header template part. A sticky block sticks only within its parent, so a block inside the header stops as soon as the header scrolls away. The Position panel also only appears for Group blocks at the root of the template.

Does a sticky header work on mobile?

Yes, but test it carefully, since a tall header can cover a third of a phone screen when stuck. GeneratePress lets you set sticky navigation to Mobile only, Desktop only or On, and its Hide when scrolling down option returns the header only when the reader scrolls up. Keep the sticky header short on phones.

Can the sticky header hide when I scroll down?

Yes, if your theme offers it. GeneratePress has a Hide when scrolling down setting that hides the navigation while scrolling down and shows it again on scroll up. A header that hides gives readers more room to read, while a header that stays visible keeps the menu one click away.

Why does my sticky header cover section headings?

A sticky header can cover the heading when a reader jumps to a page anchor, since the header sits on top of the target. Leave extra top spacing on anchored sections, or use a scroll margin on headings so the heading lands below the header. Test every anchor link from the sticky header after setup.

Does a sticky header slow down my site?

A sticky header on its own adds almost nothing, since it is one CSS rule or one block setting. The cost comes from what the header holds, such as a large logo image or a heavy menu script, not from the sticky setting itself. Keep the logo file small and the header short.

Should I use a plugin for a sticky header?

Start with the theme setting, since the theme author built it against the theme header markup. If the theme has none, use the Group block Sticky setting in a block theme, or CSS position: sticky in a classic theme. A plugin is the last resort, for effects such as shrinking the header on scroll.

Sources

  1. Sticky position block support Make WordPress Core
  2. Appearance Tools Developer.WordPress.org
  3. Sticky Navigation Learn GeneratePress
  4. position MDN

Is your product missing, or something out of date?

Tell us what to add or correct. We read every note and reply when we need a source. A message does not buy a ranking.

About the editors

Written and checked byWPLegible Editorial Team Independent WordPress reviews and guides

Researched from the primary sources listed above and checked against our editorial rules before publishing.