As a website owner, there are various scenarios where you might need to insert code into the header and footer sections of your WordPress website. This code insertion allows you to integrate third-party services, add tracking codes, customize your website’s appearance or functionality, and optimize it for search engines.
By understanding how to insert code into the header and footer, you gain the flexibility and control to enhance your website’s functionality and achieve your desired customization, such as adding analytics tracking, embedding widgets, integrating social media buttons, or modifying the overall site design.
Many WordPress themes and plugins require you to insert specific codes into the header and footer sections of your site to function correctly. Here’s a straightforward guide on how to insert code in the header and footer of your WordPress website using a plugin.
Installing and Activating Plugin
The first step is to install and activate a plugin that allows you to insert code in the header and footer sections of your WordPress website. One popular plugin for this purpose is “Insert Headers and Footers.” Here’s how you can install and activate it:
- Log in to your WordPress dashboard.
- Navigate to “Plugins” on the left sidebar and click on “Add New.”
- In the search bar on the top right, type “Insert Headers and Footers.”
- Look for the plugin named “Insert Headers and Footers” by WPBeginner.
- Click on the “Install Now” button next to the plugin.
- After installation, click on the “Activate” button to activate the plugin.

Inserting Code in the Header and Footer
Now that you have the plugin installed and activated, you can easily insert code into the header and footer of your WordPress website. Here’s how to do it:
- From the WordPress dashboard, navigate to “Settings” on the left sidebar and click on “Insert Headers and Footers.”
- You’ll be taken to the plugin’s settings page. You’ll see two text boxes: one for the header and one for the footer.
- To insert code in the header, copy the code you want to add and paste it into the “Scripts in Header” text box.
- To insert code in the footer, copy the code you want to add and paste it into the “Scripts in Footer” text box.
- Once you’ve pasted the code, scroll down to the bottom of the page and click on the “Save” button to save your changes.

That’s it! The code you inserted will now be added to the header or footer of your WordPress website, depending on where you pasted it using the plugin.