Have you ever been asked to add some code snippets to the <header> or <footer> section of your WordPress website?
When you integrate with web services such as Google Analytics and Facebook Pixel, you will often be asked to add header or footer code to WordPress.
WordPress does not allow you to insert code into your website’s header or footer by default. However, for beginners, there’s an easy solution.
This article will demonstrate how to add footer and header code to WordPress. This article aims to allow you to add code safely without having to modify your WordPress theme files.
How to add WordPress Footer and Header code
Three options are available if you need to add a WordPress footer and header code.
- Manually edit your theme’s header.php or footer.php files
- Your theme’s built-in header and footer codes
- Use a plugin
This option is not for beginners because you need to manually edit the header.php or footer.php files to add header code.
This method has a disadvantage: your code may be deleted if you update your theme.
You can also use your theme’s built-in feature. Some WordPress themes, such as Elegant Templates or Genesis Framework from StudioPress, offer an option to quickly add code and scripts to your WordPress footer and header.
It is safe and easy to use a theme that has a built-in feature. All code snippets added to your site will disappear if you change your theme. This includes website verification via Google Search Console, website analytics via Google Analytics, and many other things.
We recommend that users use the third option: a headers or footers plugin. This is the simplest and most secure way to add header or footer code to WordPress.
Our team created a free Insert Footers plugin that allows users to add code to the footer and header in WordPress.
You can read the text version below if you don’t wish to view the video tutorial.
WordPress: Adding code to the Header and Footer
The Insert Footers and Headers plugin must be installed and activated first. You can find more information in our step-by-step guide on how to install a WordPress plugin
After the plugin has been activated, you can go to Settings >> Insert Headers and Footers in your admin panel. You will see two boxes to add code to the header and footer.
Copy the code into one of the boxes. Then, to save your changes, click on the Save button.
Now, the plugin will automatically load the code at the appropriate locations on your WordPress website.
Any code you don’t wish to keep can be edited and removed at any time.
You will need to keep the plugin activated and installed at all times. What can deactivate the plugin anytime to stop adding custom code to your website?
The code will remain safe in your WordPress database if you accidentally disable the plugin. However, the code will appear again if you reinstall the plugin or activate it.
Please Note: After saving your changes, you may need to clear the WordPress cache so that the code appears appropriately on your website’s front end.
The main reason that many beginners use the Insert Headers & Footers plugin to add Google Analytics is what we have discovered. We recommend the free MonsterInsights plug. This is the best Google Analytics plugin that WordPress offers. It lets you set up Google Analytics tracking in just a few clicks and shows you valuable stats from your WordPress dashboard.
This article will help you add headers and footers codes to WordPress. Also, check out our comparison of the top email marketing services and the top business phone services.
Subscribe to our YouTube Channel to receive WordPress video tutorials. You can also find us on Twitter or Facebook.