While some theme frameworks like Genesis have a built-in option for quickly adding code and scripts to your WordPress header or footer, we here at WPBeginner have worked on numerous sites and custom themes where this functionality doesn’t exist. Most users, however, will certainly want to add some sort of meta information or Google Analytics to their WordPress blog at some point.
To solve this problem, and empower the users, we use a custom plugin on our sites called Insert Headers and Footers for WordPress. Not only is it extremely simple and easy to use without a bunch of confusing options, the biggest advantage is that instead of having to use a dozen different plugins to add various scripts and meta tags to your header or footer you can just add them all in one spot. In this tutorial we are going to show you how to insert code to you WordPress header or footer using this simple plugin.
Video Tutorial
If you donít like the video or need more instructions, then continue reading.
First, download and install Insert Headers and Footers for WordPress. Now go to Settings » Insert Headers and Footers.
Here you see two text boxes where you can add your code. Simply copy and paste any meta information, scripts, Google Analytics, etc. and click “save settings”. This code will now be output to either your header or you footer.
Download Insert Headers and Footers for WordPress
I wish this was available for Premium Accounts as well as Business. Is there another way to embed code in your site
Hi Claire,
You are probably using WordPress.com. Please see our guide on the difference between self hosted WordPress.org vs free WordPress.com blog.
This has been quite helpful!
I’ve installed header and footer plugin, entered the relevant code and saved it. When I look in header script in header editor I can’t see the relevant code I’ve just entered. Please advise.
Thank you.
Hello, is there a way to insert header code only to certain posts or to posts in a certain category?
When I try to add header code using the plug in I get a 403 forbidden page. How do I get around this? I temporarily tried to turn off my security but that didn’t help.
Hi Randy,
Please see our guide on how to fix 403 forbidden error in WordPress.
Hi, Iam looking for option like this but for a multi-site,
but I need is like a general admin for network-wide option,
where when i config this, it will show to the header on all sub-site,
currently, I need to set this for every sub-site plugin config.
is there any way to have the plugin option of this menu under network option or something and not per sub-site.
is there any other option i can use/do.
thanks
Hey, is there anyway to check if the code has been inserted ? Can’t detect it in my site source code nor in the headers.php file. Is is possible for this plugin to not be working ?
Hi Riddhi,
Once you add the code and save your changes you will be able to see the code in your site’s source code. For header code you will find it between <head> and </head> tags. Footer code will be added before the </body> tag.
Is there a way to use this to add an image in the header that does not replace the existing header? In other words, I already have a logo there on the left, and a search bar with social media links on the right. The center is empty. I want to add an image widget which links to the source page of the image. I have the widget code ready to insert, but there is no HTML showing in the header.php file. I do not know PHP (i do know HTML quite well).
I added the widget to the footer, which was easy because in my theme there IS HTML (an HTML table) in the footer. But it is supposed to be at the top of the pages.
Any idea when this plugin will be updated for WP 4.9.1? Looks like it’s only compatible up to 4.8.4
Hi Ralph,
You can safely install the plugin. For more on this topic please see our article should you install plugins not tested for your WordPress version.
Thank you so much for information. I have been so much problem with pasting html adsense code in header. This information helps me a lot
So, can I disable this notification after install anywhere?
I don’t need all my multisite clients to see this notification!!
When I add my code into the header or footer section in the plugin, does it apply it across all my pages? Thanks.
Hi Brandon,
Yes, it would apply to all pages on your website.
HI
How do i add the code to a single page header (not a post) so it appears only on that page?
Hey Rolland,
This plugin will add header and footer code to all pages and posts. If you want to add it to just a single page, then you will have to manually add your code to your theme and surround it with a conditional php tag. For example:
Don’t forget to replace 22 with your actual page ID.
hi, I just re-added my footer widget embedded code, it’s from keyreply.
I don’t know what’s went wrong, I could see my footer widget from my pc(while I am logged in WP), however any other devices(pc or mobile phone), the widget is not showing. any ideas?
im a new leaner and im facing problem in converting footer content in to dynamic wordpress content
I installed the insert headers and footers plugin on my clients WordPress site but when I click on it under settings it just shows a blank page. There are no fields available for me to insert text into.
Hi,
I’m trying to install an html5 banner ad at the top of my home page and a few other page tops. I have a customer that wants to only deliver their banner ad in that format so that as a rotating banner each image links to a different url we’re promoting. Where do I put this code to make it show up? I’ve tried downloading some plugins to place it but nothing is working. We normally just accept jpgs and links but I don’t want to lose this sale as she won’t deliver other than in html5. Thanks for your help! Geraldine
Hello,
Please take a look at Adsanity plugin.
Hi, I love the simplicity of this plugin. There is one annoying point however.
How can I disable the dashboard notice “Thank you for installing….” in a multisite set up.
I don’t need all my client sites seeing that notice.
A solution that doesn’t involve another plugin would be appreciated, preferably I can just remove an action or something.
Does that mean that I can’t disable the notice? (without hacking the plugin)
Adsense give me copy code in to my site (between head) , where I can put code into my site?? I use premium plan!
Hi Rattanak,
You cannot use Adsense on WordPress.com premium plan, you will need at least their business plan for that. Please see our guide on the difference between self hosted WordPress.org vs free WordPress.com blog.
Hi,
Your team member has tried to resolve my issue and they are on time .. but i just saw this place where we can leave a reply..
I am trying to add a meta tag to my front page as required by my affiliate programm company to get to promote their product. I used add header and footer plug in as suggested by your team member and after adding and saving changes I do not see the changes .. how would the site look after adding the meta tag by the way the meta tag is as below
OR the other option is to add a new page with their code which is .html . i tried to copy paste as but it remains as such. IS IT BECAUSE MY SITE IS PHP SUPPORT AND THE CODE IS HTML OR HOW?
Hope to recieve your advice and feedback.
Hi Madhusudan,
The meta tags are located in your website’s HTML code. They are added in the header section or at the end. Meta tags are not visible on your website and do not make any change to your website’s appearance. You can still view the meta tag by viewing the source or using the inspect tool.
I have added the header/footer plug in. I added my facebook pixel code and hit saved. But how to I install this code to specific pages of my website so I can track certain conversions?
I use this plug-in all the time with no issues. Today, I installed it and added my code needed into the correct area. Every page is showing the code except the home page. Any idea why every page would have the code except the home page?
This post doesn’t teach what script to put in the footer though. What simple script can I use to get started? I just want a simple footer.
I am having an issue her. It would be very helpful of you to resolve my issue.
I have to add the code of google adsense in the header of my website, but earlier i had added the instant article code in the header, now what shold i do to keep both of them?
(As i am the beginner, so i don’ know much about it. Help me please.)
I tried installing the “Insert Headers and Footers” into my website. When I go to “Settings/Insert Headers and Footers”, I get this error: (Fatal error: Call to undefined function wp_unslash() in /home/afvetrep/public_html/wp-content/plugins/insert-headers-and-footers/ihaf.php on line 169)
What do I do?
Hey George,
wp_unslash() is a standard WordPress core function since WordPress 3.6. If you are using an older version of WordPress, then you need to update WordPress.
If you are using the latest version of WordPress and still seeing this error, then let us know and we will help you troubleshoot.
Hi. I am inserting a MailChimp popup script into the footer and this breaks my WP main navigation menu. Any idea why or how to fix it ? I just upgraded to your latest plugin version but the problem persists. Thanks.
Anyone have any idea why I have this problem ?
Thanks !
Please help me
I can’t see any editor on appearance..
I need to put webmaster tool verify meta code in how can I edit the header?
Need help
Thank you very much. Please where can I paste Google AdSense code in this plugin, header or footer?
Hi, I can’t see any
I’m trying to connect my WB with Adsense
Can i add Adsense ad code on WordPress after using mobile???
Please help
Hi, can this still be used to insert the code that one is given for verification of a Google Adsense account?
Yes it can be used for that.
This is one of my best plugins and i use em frequently to add codes to the header and footer, but something happen after i update the plugins few hours ago, it gave an error [Fatal error: Can’t use function return value in write context in /home/campmmcg/public_html/wp-content/plugins/insert-headers-and-footers/ihaf.php on line 102]
Please resolve this
Hi Samuel,
This issue has been fixed in version 1.4.1, please update the plugin.
This was really easy but it changed my header on the website and it is huge! It has pushed down my slider and my content for a huge white box. Help!
hey thanks for this amazing plugin
but could it work if i paste google verification code on the header
Thank you for this greate article, my question can I use this plugin to insert ad codes like ad codes of affiliates programs?
Hellow.. i am using this plugin, I have a question that can i use this plugin to insert multiple codes in this way..
Code 1
Code 2
Code 3
Simply Code 1 and then Enter Button and code 2 and enter button.
I want to insert codes likes google authorship, analytics, webmaster, etc.
Hey Rizwan,
Yes you can multiple code snippets on new lines by pressing enter button after pasting each snippet.
Hi, This is probably a silly question, but if I already installed a facebook script in the header and now want to install another one from Hotjar, I am deleting the prior Facebook script so it is not re- installed, correct? Sorry I am not well versed in code.
Thanks
Hi Isabella,
Yes it is ok to do that. If you are unsure, then you can just copy the old code and save it as a text file on your computer.
Excellent video. Very clear and helpful. I am now subscribing to your channel.
good day. without installing any wp theme,is there any way I can use my own theme. or template
Superb Plugin….
This is grat plugin, I see it is more than one year without updates. Could you please update it?
Vladimir
Thanks so much for the video. I tried to figure this out through other websites, and with my own brain, but I was still unsure. Your video was short and sweet, and finally gave me the visuals I needed to get the job done. Thanks again!
You are welcome
hi ,
i want to add my logo from wp(dynamic logo)
where is this plugins >?
hey amazing people, i installed and added FB instant article code but FB still says that the code is not in the website.
I have added it to head section part.
I get “403 Forbidden
A potentially unsafe operation has been detected in your request to this site.”
when I insert the google script
Thank you! Being very new to site building, and with no experience with working with coding, this was easy to follow!
Glad you found it helpful.
hi i am new in wp…….how to make database in wp and create table insertion etc….
Hello! I am using Insert Headers and Footers to add the Google Analytics code to my WP site. Do I need to worry about each page on my site separately or am I covering the entire site simply by following the instructions on this video and adding the code to the Headers box (Insert Headers and Footers > Settings)?
You are covering the entire site.
Do you have html code or something, i need it to make my site faster
No more plugin
Thanks
Hello !
This would be my first time using your plugin. I am hoping to render my web site more secure by adding these following scripts in the header :
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 1; mode=block
My questions are : Can I use your plugin to do this and if so do I make the header addition scripts one at a time or as I have typed them here.
Thanks for your help !
The more appropriate way to set HTTP headers in WordPress is by using the send_headers hook. Here is an example, it goes in functions.php file.
Hi,
I’m new to WPBeginner.com, and this is the first tutorial I have viewed. To be blunt, I’m stunned that a tutorial says “Here you see two text boxes where you can add your code. Simply copy and paste any meta information, scripts, Google Analytics, etc. and click “save settings”. This code will now be output to either your header or you footer.”
Regrettably, there are no links to information that helps a beginner understand how to get, or use, any of the code indicated. This renders the plugin useless to me.
My use for this plugin is to use it for connecting to pages such as privacy policy and publisher disclaimer. Is there a tutorial somewhere that shows this? if so, please link to it from this page.
If your theme has a navigation menu in the footer area, then please see our guide how to add navigation menu in WordPress.
Can Headers be static menus that include text, graphics, and links to pages? Same for Footers.
is my site and is developed using FrontPage. We want to simply convert the entire site to Word Press as simple as possible. All links are to other site pages, site PDF and Word files, and a few external links. No Forms, No dynamic database, NO searches.
any help would be appreciated
Same result from inserting in wp_head Hook in Genesis Simple Hooks? Worked for me.
Yes it is.