Skip to content

How to modify the header in WordPress

“Modify the header” in WordPress can mean four jobs: the visible header, the code in the page head, the HTTP response headers, or the “headers already sent” error. Each one has its own place to make the change. Most failed header edits are correct edits made in the wrong place, so start by working out which system controls your header.

On this page
  1. Which header are you trying to change?
  2. Find out what controls your visible header first
  3. How to edit the header in a block theme
  4. How to edit the header in a classic theme
  5. How to edit an Elementor header
  6. How to add code to the head without touching theme files
  7. When you do need header.php, use a child theme
  8. Why the header saved but nothing changed
  9. How to fix “Cannot modify header information”
  10. How to add HTTP response headers
  11. What a correct result looks like
  12. When the theme can’t produce the header you want
  13. Frequently asked questions

Key takeaways

  • On a block theme the header is a template part under Appearance > Editor. On a classic theme it is under Appearance > Customize. If Elementor’s Theme Builder has a published header, Elementor controls it.
  • Creating a menu does not put it in a block-theme header. You have to select the Navigation block and choose that menu.
  • Verification tags and analytics scripts belong in a code-insertion plugin such as WPCode, with the full script tags included, not in a parent theme’s header.php.
  • For “Cannot modify header information”, fix the file and line after “output started at”. The file the warning names first is usually only where the failure showed up.
  • If a header saves but looks unchanged, check four things in order: the editor you used, every cache layer, the page template (Elementor Canvas hides the header), then plugin conflicts.

Four different jobs show up under the words “modify header” in WordPress. Someone wants a new logo or menu. Someone else needs to paste a Google verification tag. A third person needs a security header from the server. A fourth is staring at a PHP warning that says “Cannot modify header information.” Each job happens in a different place, and the most common failure is a correct edit made in the place that doesn’t control the live site.

Which header are you trying to change?

Pick your row before you open anything.

What you wantWhat it isWhere you change it
Logo, menu, layout, colours, sticky behaviourThe visible site headerSite Editor, Customizer or theme options, or a page builder
Verification tag, analytics script, meta tagThe HTML <head>A code-insertion plugin, or a child theme
Security, caching or CORS headersHTTP response headersThe Redirection plugin, your host’s panel, or server config
“Cannot modify header information – headers already sent”A PHP errorThe file and line after “output started at”

Find out what controls your visible header first

Open the Appearance menu in wp-admin. If you see Editor, you’re on a block theme and the header is a template part. If you see Customize and no Editor, it’s a classic theme. Our guide to telling block and classic themes apart walks through the same check.

Then check for a builder. If Templates > Theme Builder in Elementor has a published header, Elementor controls the header and the theme’s settings won’t change it. Some commercial themes have their own panel too. One Avada user on Reddit found the controls under Appearance > Theme Options > Header after searching everywhere else.

How to edit the header in a block theme

  1. Go to Appearance > Editor.
  2. Open Patterns, then Template Parts, then Header. Labels shift a little between WordPress versions, but the header is always a template part.
  3. Edit the blocks: Site Logo, Site Title, Navigation and any button or announcement row.
  4. To change the menu, select the Navigation block and choose the menu in its settings. Creating a menu somewhere else doesn’t put it in the header.
  5. Click Save. The change applies to every template that uses this header part.

Here’s a catch developers run into: after you save, WordPress keeps your version in the database and uses it instead of the theme’s parts/header.html. Editing that file later changes nothing until you reset the template part’s customizations in the Site Editor. The guide to WordPress drop-down menus covers the Navigation block in more detail.

How to edit the header in a classic theme

Go to Appearance > Customize. Three panels do most of the work:

  • Site Identity: logo, site title and tagline. If an oversized title appears above your menu, untick “Display Site Title and Tagline” here.
  • Menus: assign a menu to the header location the theme registers.
  • Header Image: only appears if the theme supports a custom header.

Click Publish when the preview looks right. A classic theme only lets you change what it exposes. If the panel you need isn’t there, you can either live with the limit or make a code change in a child theme. You can’t fix it from the settings screen.

How to edit an Elementor header

Go to Templates > Theme Builder > Header, edit the template and click Publish. Elementor then asks for display conditions, such as the entire site or specific pages. A header that shows on some pages and not others is usually a condition problem. It’s rarely a design problem.

Check the page template as well. Elementor Canvas deliberately leaves out the header and footer. In a resolved WordPress.org support thread, switching a page from Canvas to Elementor Full Width brought a missing header back.

How to add code to the head without touching theme files

Use a code-insertion plugin. In WPCode, the steps are:

  1. Go to Code Snippets > Header & Footer.
  2. Paste head code (verification tags, analytics) into the Header field. Include the opening and closing <script> or <meta> tags. If you leave out a script wrapper, the code can print on the page as plain text.
  3. Paste code the provider says belongs right after <body> into the Body field. This only works if your theme calls wp_body_open, the hook WordPress fires after the opening body tag.
  4. Save, then view the page source on the live site and search for your tag.

WPCode’s documentation says code added this way stays in place when you switch themes, because it lives in the plugin. A pasted tag in header.php disappears with the next theme update.

WPCode Header and Footer screen for adding code to the WordPress header
Pasting complete script tags directly into the Header field ensures custom code loads cleanly inside the site’s head section. · Source: wpcode.com

When you do need header.php, use a child theme

In a classic theme, header.php contains the document head and calls wp_head(). Plugins print their scripts and meta tags through that hook. Edit the parent theme’s copy and the next update overwrites it.

Back up first. Then create a child theme. Often you don’t need to copy header.php at all, because a hook in the child theme’s functions.php is smaller and safer:

add_action( 'wp_head', function () {
    echo '<meta name="example-verification" content="abc123">' . "\n";
} );

Only copy header.php into the child theme when you need to change its markup. Don’t copy the parent’s functions.php. WordPress’s Theme Handbook warns that duplicated function names cause fatal errors. Our article on theme customization that survives updates covers the child-theme setup.

Why the header saved but nothing changed

These usually fail silently, with no error. Check them roughly in this order:

  1. You edited the wrong layer. The live header comes from a Site Editor template part, a builder template or a database customization, but the edit went into header.php, a pattern or the page content.
  2. A cache is serving the old header. WordPress.org’s FAQ lists browser cache, server-side cache and caching plugins as separate causes. Add your CDN and object cache to that list. Logged-in users often skip the page cache, so check in a private window. On Elementor, regenerate CSS and data after clearing caches.
  3. The page template hides the header. Elementor Canvas, a theme’s “blank” template, or display conditions that leave the page out.
  4. A conflict. Two header systems are active, or a plugin interferes. In one WordPress.org thread, a Polylang connector hid Elementor headers until the display conditions were saved again. Switch to a default theme and turn plugins off one at a time to find it.

How to fix “Cannot modify header information”

This PHP warning means something printed output before WordPress tried to send a header, a cookie or a redirect. The message looks like this:

Warning: Cannot modify header information - headers already sent by
(output started at /wp-content/themes/child/functions.php:34)
in /wp-includes/pluggable.php on line 1450

Fix the file after “output started at”, not the one after “in”. WordPress’s Advanced Administration Handbook names the usual culprits:

  • blank lines or spaces before <?php or after a closing ?>;
  • a UTF-8 byte order mark (BOM) your editor saved invisibly;
  • a redirect that runs after the page has started printing.

In a PHP-only file, leave out the closing ?> completely. For redirects, run them on template_redirect and stop execution, because wp_redirect() doesn’t exit on its own:

add_action( 'template_redirect', function () {
    if ( is_page( 'old-offer' ) ) {
        wp_redirect( home_url( '/new-offer/' ), 301 );
        exit;
    }
} );

If a core file is damaged, replace it from a backup or a fresh WordPress download. The guide to redirecting a page without losing traffic covers the non-code routes.

How to add HTTP response headers

These are set at the server, not in the page. With the Redirection plugin, go to Tools > Redirection > Site and use the HTTP Headers section. Add a header name and value, choose whether it applies to the whole site or only to redirects, and save. Picking “redirects” for a header meant for every page is a common mistake.

Purge caches. Then open your browser’s developer tools, reload, and read the response headers in the Network tab. Some managed hosts restrict certain headers, so check your host’s panel if one won’t stick.

What a correct result looks like

Check the live site in a private window, logged out, at phone width. Open and close the mobile menu, scroll to test any sticky behaviour, and make sure the sticky header doesn’t cover page titles. Then tab through the header with the keyboard.

The W3C’s accessibility tutorials recommend putting the main menu in a labelled <nav> region. A <header> nested inside an <article> or <section> is not the page-wide banner. Custom header markup should keep both points intact.

WordPress header checked at phone width with the mobile menu open
Testing the mobile viewport confirms that the slide-out navigation opens smoothly and displays nested menu links without breaking the layout. · Source: wordpress.org

When the theme can’t produce the header you want

Sometimes there’s no setting to find. In a 2026 WordPress.org thread, a Storefront user wanted the account, cart and search on one line. Storefront doesn’t do that by default. Moving My Account into the primary menu got partway there, and the owner kept the simpler header.

At that point you have three options: accept the theme’s layout, rebuild the header in a builder, or have the markup changed in a child theme. If you want the third option done for you, SiteSelf makes header and layout changes on an existing site from a chat request. It needs hosting access for template files, and it refuses headers owned by Elementor, Divi or Beaver Builder.

Frequently asked questions

Can I use a different header on different pages?

On a block theme, create a second header template part and use it in the templates that need it. In Elementor, publish a second header and give it its own display conditions. Classic themes only offer this if the theme supports it.

Can I modify the header without a plugin?

For visual changes, usually yes, through the Site Editor or the Customizer. For scripts and meta tags, a plugin is the simplest route. The alternative is a wp_head hook in a child theme, which needs file access.

Will a theme update erase my header changes?

Edits to the parent theme’s files will be erased. Site Editor changes, Customizer settings, builder templates and code-plugin snippets are stored separately and survive theme updates. Child-theme files survive as well.

Why is my header suddenly taller than before?

Check the logo file first. Transparent padding inside the image counts as part of the logo’s size, so cropping the image often fixes it. If the logo is fine, look at padding on the header group or a newly added announcement row.

How do I add noindex to a few specific posts?

Use your SEO plugin’s per-post setting if you have one. Otherwise, add a conditional wp_head hook in a child theme, or a snippet in a code plugin with page conditions.

Give your WordPress site its first task.

Connect the site you already have, add your agent to Slack or Telegram, and tell it what you need.

Connect your site

Start with 500 free credits. No credit card needed.