Skip to content

How to Add Header and Footer Code in WordPress [Easy Methods]

Key Takeaways

  • WordPress does not offer a direct way to add header and footer code, so the post uses plugins or manual code snippets instead.
  • Header, Footer, and Post Injections adds custom code snippets in Settings > Header and Footer, with separate fields for every page, homepage, desktop, and mobile.
  • Nexter Builder creates custom header and footer templates by selecting Sections > Header or Sections > Footer and setting Display Rules.
  • Nexter Blocks adds widgets such as business logo, navigation menu, search features, CTA banners, social icons, Google Maps, and contact forms to headers and footers.
  • functions.php accepts custom header code with add_action( 'wp_head', 'custom_header_code' ) and footer code with add_action( 'wp_footer', 'custom_footer_code' ) in a child theme.

Sometimes, you’ll need to add header and footer code to the WordPress site. This could be for things like adding custom CSS, tracking scripts (like Google Analytics), or meta tags for better SEO.

Many tools or services ask you to insert this code to make them work correctly. While WordPress doesn’t offer a direct way to do this, there are simple methods you can use, like plugins or adding a code snippet manually.

In this article, we’ll show you two easy ways to add code to your WordPress header and footer. Let’s get started!

Table of Contents

What are the Header and Footer on the Website?

The header and footer on the website are the top and bottom sections that remain consistent across the various pages.

The header is the top area of the website that can include the company logo, navigation menu, site search features, or a CTA for a seamless web experience. While the header can determine the website’s style with a consistent design, you can also have different headers on each site page.

Similarly, the footer is the section at the bottom of the website with useful information such as links to other site pages, business contact details, terms of use and privacy, business location map, and much more.

Often neglected, the header and footer are key aspects of a website’s design that simplify the navigation and offer useful information to the site visitor, enhancing the overall website experience.

Why Add Code to Your Header and Footer?

There are various reasons for adding header and footer code in WordPress. One of the most common reasons would be to customize the design of the header and the footer using a custom code.

Additionally, there are various plugins or web services that require you to add a code in the footer header to function properly. For instance, you might want to add tracking scripts to integrate Google Analytics to monitor the website traffic. Or you might want to add meta tags to optimize your website for search engines and achieve higher rankings.

Adding a code in the header and footer makes it easy to integrate such customizations on your website without editing the theme’s source code.

How to Add Header and Footer Code in WordPress?

Wondering how to edit the head in WordPress or how to make a footer in WordPress to add a code? Here are two simple ways to do so.

Method 1: Using a Plugin

One of the easiest ways to add code to the footer header in your website is to use a WordPress plugin like-

Here, we will explore how you can use the Header, Footer, and Post Injections plugin to add code to website header and footer-

Step 1: Install and activate the plugin

Go to Plugins > Add New on your WordPress dashboard and search for the Header, Footer, and Post Injections plugin or other plugin of your choice.

Install and activate the plugin.

Step 2: Add the code snippet to the header and footer

Once the plugin is activated, go to Settings > Header and Footer on the dashboard.

Here, you’ll see various text fields where you can add a custom code snippet for tracking code or a custom JavaScript.

In the first two fields, you can insert a code snippet to the website’s header. Within this, the left field lets you add a custom code snippet to every page on your website, while the right field will help you add a code only to the homepage.

Similarly, you can add a code snippet for the website footer in the last two fields. Within this, the left field is for desktop viewing, and the right field is for adding a code for the mobile website.

Once you’ve added the code snippets for the header and footer, save the changes, and you’re good to go!

Step 1: Create a Header Template

Install and activate the Nexter theme from the WordPress library and go to Nexter Builder > Add New on your WordPress dashboard.

In the Nexter Builder, select Sections > Header from the layout options. This will allow you to create a custom header for the website, which you can easily customize using Display Rules.

Set Display conditions based on your requirements.

Step 2: Customize the Header

Now, you can use the Nexter Blocks in WordPress to edit the head section and add widgets for design and content. For instance, you can use different widgets to add the business logo, navigation menu, search features, or CTA banners in the header.

Simply click on the ‘+’ sign to add the column block and add the widgets you want to. For each block, you can use the advanced settings to customize the layout, colors, background, sizing, and more.

Step 3: Design the Footer

To add a footer to your website, follow the same steps as for the header.

However, in the Nexter Builder, select Sections > Footer from the layout options and use the Nexter Blocks to add widgets, social icons, Google Maps, or contact forms to enhance the website experience.

Once you know how to insert the footer and header in WordPress, you can use the plugin mentioned above to add a header and footer code in WordPress.

Method 2: Manually Adding Code to functions.php

Manually adding a code to the website header and footer isn’t too complex, though it requires you to perform a few technical steps.

Step 1: Create a child theme

Adding a code to your header and footer manually requires editing the website theme files. However, editing the parent theme will overwrite your customizations every time you update it. As a result, it is better to create a child theme to modify the parent theme without losing the customizations.

For this, you can use a theme builder plugin to create a child theme for your website.

Step 2: Add a code to the theme’s functions.php file

Once you’ve set up the child theme, access its functions.php file to add the code.

1. You can either do it via FTP and an FTP client such as FileZilla or edit certain theme files via Appearance > Theme Editor on your WordPress dashboard.  

2. In the Theme Files section on the right, click on the “Theme Functions (functions.php)” file.

3. Add the following code to your functions.php file and replace “YOUR_CODE_HERE” with your custom code-

For Header-

For Footer-

  1. Click on the Update file to save your changes.

Stay updated with Helpful WordPress Tips, Insider Insights, and Exclusive Updates – Subscribe now to keep up with Everything Happening on WordPress!

Wrapping Up

Adding a code to your header and footer in WordPress is a great way to customize your site design, integrate Google Analytics to track website traffic, and improve the overall website experience. Fortunately, it is pretty simple to add code to the footer header using a plugin or manually by adding a code to your functions.php file.

Headers and footers are a great way to enhance the functionality of your website. With Nexter Theme Builder and Nexter Blocks, you can easily create customized headers and footers and add various features.

But that’s not it. Nexter Blocks gives you access to 90+ unique Gutenberg blocks to help you enhance the functionality of your Gutenberg editor.

FAQs on header and footer code in WordPress

When Would I Need To Add the Header and Footer Code?

You might want to customize your header and footer design with custom CSS, add tracking scripts with Google Analytics, or optimize your website for SEO. In such cases, you will be required to add header and footer codes to the site.

Why can’t I edit the header in WordPress?

WordPress does not offer any specific settings for editing the header and footer of your website. However, you can edit the header by accessing your theme files by going to Appearance > Theme Editor.

Why is my header footer not showing WordPress?

If the header footer is not showing on your WordPress, you need to create it using your theme builder. To create it, go to Nexter Builder > Add New on your WordPress dashboard. In the Nexter Builder, select Sections > Header from the layout options and create the custom header.

Where is the header file in WordPress?

You can find the header file on your WordPress dashboard. Go to Appearance > Theme File Editor > {Theme} Header.

Is it good to replace the header and footer in the Website?

Adding a header and footer on your website is an excellent way to enhance the design of your website, make navigation easy, and add contact and business location details for a seamless website experience.

Have Feedback or Questions?

Join our WordPress Community on Facebook!

Related Frequently Asked Questions

When would I need to add header and footer code in WordPress?

Header and footer code is usually added when a service needs a snippet to work, like Google Analytics tracking scripts, custom CSS, or meta tags for SEO. It also helps when you want to customize the header or footer without editing the theme’s source code directly. That matters because theme-file edits are easier to break during updates, while a snippet-based approach keeps the change isolated.

Why can't I edit the header in WordPress from the dashboard?

WordPress does not offer a built-in dashboard setting for editing the header and footer. The page points to two practical routes instead: use a plugin or edit theme files through Appearance > Theme Editor. If you need a safer long-term setup, the tutorial also recommends creating a child theme before changing functions.php so your customizations do not get overwritten by parent theme updates.

What should I do if my WordPress header or footer is not showing?

A missing header or footer usually means it has not been created in your theme builder yet. The tutorial’s fix is to go to Nexter Builder > Add New, choose Sections > Header, and build the custom header there. Nexter Theme and Nexter Blocks are used for this setup, and the same approach applies when creating a footer by selecting Sections > Footer.

Where is the header file in WordPress?

The tutorial says you can find it through Appearance > Theme File Editor > {Theme} Header. That path matters because it points you into the active theme’s files rather than a general settings screen. If you are editing code manually, this is also why a child theme is safer: it keeps your changes from being lost when the parent theme updates.

Is it better to use a plugin or functions.php for adding header and footer code?

A plugin is the easier option if you want to add tracking code or custom JavaScript without touching theme files. The manual functions.php method gives more direct control, but it requires a child theme and access through FTP or Appearance > Theme Editor. For most non-developers, the plugin route is simpler; for deeper customization, functions.php is the more technical path.

What kind of content can go in a WordPress header or footer?

The page shows both areas as useful places for practical site elements, not just code. Headers can hold a logo, navigation menu, site search, or CTA, while footers often include links to other pages, contact details, terms of use, privacy info, and even a business location map. That makes them useful for both design and site utility.

Last reviewed: August 18, 2026

About the Author

Photo of Aditya Sharma CMO of Nexter
CMO at POSIMYTH Innovations · Nexter · 7 years experience

He has spent years in the WordPress ecosystem building, breaking, and optimizing sites until they actually perform. He works at the intersection of speed, growth, and usability, helping creators ship websites that load fast and convert. An active WordPress community contributor sharing through tools, tutorials, and direct collaboration. Tested practice, not theory.

WordPressThemesElementorn8nAIClaudeAutomationServer

Related Blogs