How to Add Header and Footer Code in WordPress?Have you ever been face issues to add some code snippets to your header and footer section of your WordPress website?
Often you have to add code snippets in header and footer in WordPress to integration with web services like Facebook Pixel, Google analytics, Google Search Console etc.
By default, WordPress doesn’t have any option to add codes in header and footer section of your website. Luckily there is a best option for all users.
Today, in this post we will show you how you can easily add header and footer codes in WordPress. The aim is to add the code safely without editing WordPress theme files.
Best Way to Add Header and Footer Code in WordPress:-
There are three best possible solutions to add WordPress header and footer code:
- Manually through editing themes’s header.php & footer.php files.
- With theme’s built-in header & footer feature.
- Using plugin.
The first option is not beginner friendly because it needs you to add header & footer code by directly editing header.php & footer.php files manually.
Another drawback of this method is that your code will be removed if you update theme files.
How to Add Header and Footer Code in WordPress?
Second option is to use theme’s built-in feature. Some WordPress themes such as elegant theme and Studiopress theme offer a built-in option for quickly adding code and snippets to header and footer.
If you are already using a theme with built-in feature then it seems like safe, simple and easy to use solution.
However when you change your WordPress theme all the code snippets added to theme files will be gone. This may includes site verification in Google search console, analytics etc.
That’s why we recommend our users to use third option, a plugin for header and footer. This is far easiest and safest mode to add header and footer code in WordPress.
We recommend you to use Insert Headers and Footers Plugin to let users easily add code to header and footer in WordPress.
Following are some benefits of using Insert Headers and Footer Plugin:
- Easy, Fast and Organized:- It enables you to add codes to your website’s header and footer section easily and quickly. Also it keeps you maintained by allowing you to store all header and footer at one place.
- Prevents Errors:- It helps you to prevent errors which may occur if you edit theme files manually.
- Upgrades or change Theme without worry:- This plugin will save your header & footer codes in separate place so you can update or change theme without worrying about losing codes.
Let’s have a look How to add header and footer code in WordPress using Insert Header and footers plugin.
Adding code in Header and Footer in WordPress:
Initially you need to install and activate Insert Headers and footers plugin. Once the plugin is activated, navigate to Settings>> Insert header and footers from admin panel. After that you will find two boxes to add header and footer code.
Simply paste the code snippet in appropriate box. Once done, click on save changes to store the settings. Now the plugin will load the code automatically in respective locations on WordPress site. You can edit and remove code anytime that you don’t want to keep.
You’ll need to keep the plugin installed & activate all times. Deactivating the plugin will remove custom code added on your site.
If you have deactivated the plugin accidently then your code is safely stored in WordPress database. You can simply reinstall & activate the plugin and the code will start appearing on your website.