WPBeginner

Beginner's Guide for WordPress

  • Blog
    • Beginners Guide
    • News
    • Opinion
    • Showcase
    • Themes
    • Tutorials
    • WordPress Plugins
  • Start Here
  • Deals
  • Glossary
  • Videos
  • Products
X
☰
Beginner's Guide for WordPress / Start your WordPress Blog in minutes
Choosing the Best
WordPress Hosting
How to Easily
Install WordPress
Recommended
WordPress Plugins
View all Guides

WPBeginner» Blog» WordPress Plugins» How To Add Header And Footer Code In WordPress

How To Add Header And Footer Code In WordPress

Last updated on August 18th, 2014 by Editorial Staff
558 Shares
Share
Tweet
Share
Special WordPress Hosting offer for WPBeginner Readers
How To Add Header And Footer Code In WordPress

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

Subscribe to WPBeginner

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.

Insert Headers and Footers for WordPress

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

558 Shares
Share
Tweet
Share
Popular on WPBeginner Right Now!
  • Why Build Your Email List Today

    Revealed: Why Building Your Email List is so Important Today!

  • Step by Step Guide: How to Start a Podcast with WordPress

    How to Start Your Own Podcast (Step by Step)

  • Error Establishing a Database Connection in WordPress

    How to Fix the Error Establishing a Database Connection in WordPress

  • Checklist

    Checklist: 15 Things You MUST DO Before Changing WordPress Themes

About the Editorial Staff

Editorial Staff at WPBeginner is a team of WordPress experts led by Syed Balkhi. Page maintained by Syed Balkhi.

The Ultimate WordPress Toolkit

104 Comments

Leave a Reply
  1. Claire Plaisted says:
    Apr 5, 2018 at 7:56 am

    I wish this was available for Premium Accounts as well as Business. Is there another way to embed code in your site

    Reply
    • WPBeginner Support says:
      Apr 5, 2018 at 8:21 pm

      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.

      Reply
  2. Iboro William says:
    Mar 16, 2018 at 2:44 am

    This has been quite helpful!

    Reply
  3. Mo says:
    Mar 13, 2018 at 3:53 am

    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.

    Reply
  4. Alex says:
    Mar 7, 2018 at 2:13 pm

    Hello, is there a way to insert header code only to certain posts or to posts in a certain category?

    Reply
  5. Randy Trelka says:
    Jan 31, 2018 at 8:14 pm

    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.

    Reply
    • WPBeginner Support says:
      Feb 4, 2018 at 3:23 pm

      Hi Randy,

      Please see our guide on how to fix 403 forbidden error in WordPress.

      Reply
  6. Prolete Atienza says:
    Jan 24, 2018 at 5:03 am

    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

    Reply
  7. Riddhi says:
    Jan 16, 2018 at 2:22 am

    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 ?

    Reply
    • WPBeginner Support says:
      Jan 16, 2018 at 9:44 am

      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.

      Reply
  8. Debbie says:
    Dec 27, 2017 at 6:31 pm

    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.

    Reply
  9. Ralph Machin says:
    Dec 15, 2017 at 5:00 pm

    Any idea when this plugin will be updated for WP 4.9.1? Looks like it’s only compatible up to 4.8.4

    Reply
    • WPBeginner Support says:
      Dec 16, 2017 at 5:50 pm

      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.

      Reply
  10. Jesse says:
    Dec 15, 2017 at 8:04 am

    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

    Reply
  11. Gareth Parmar says:
    Nov 21, 2017 at 6:23 am

    So, can I disable this notification after install anywhere?
    I don’t need all my multisite clients to see this notification!!

    Reply
  12. Brandon says:
    Nov 8, 2017 at 7:12 pm

    When I add my code into the header or footer section in the plugin, does it apply it across all my pages? Thanks.

    Reply
    • WPBeginner Support says:
      Nov 10, 2017 at 6:07 am

      Hi Brandon,

      Yes, it would apply to all pages on your website.

      Reply
      • Rolland says:
        Apr 4, 2018 at 5:23 am

        HI

        How do i add the code to a single page header (not a post) so it appears only on that page?

        Reply
        • WPBeginner Support says:
          Apr 4, 2018 at 5:26 pm

          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:

          if (is_page( 22 )) { 
          // your code goes here
          } 
          

          Don’t forget to replace 22 with your actual page ID.

  13. melody says:
    Oct 14, 2017 at 12:22 am

    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?

    Reply
  14. Prava says:
    Oct 10, 2017 at 5:35 am

    im a new leaner and im facing problem in converting footer content in to dynamic wordpress content

    Reply
  15. Wendy K says:
    Oct 9, 2017 at 1:00 pm

    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.

    Reply
  16. Geraldinesmythe says:
    Sep 26, 2017 at 10:24 am

    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

    Reply
    • WPBeginner Support says:
      Sep 27, 2017 at 4:26 pm

      Hello,

      Please take a look at Adsanity plugin.

      Reply
  17. Gareth says:
    Sep 21, 2017 at 4:28 am

    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.

    Reply
    • Gareth says:
      Nov 10, 2017 at 8:31 am

      Does that mean that I can’t disable the notice? (without hacking the plugin)

      Reply
  18. Rattanak says:
    Sep 1, 2017 at 4:43 pm

    Adsense give me copy code in to my site (between head) , where I can put code into my site?? I use premium plan!

    Reply
    • WPBeginner Support says:
      Sep 4, 2017 at 12:33 am

      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.

      Reply
  19. MADHUSUDAN says:
    Aug 15, 2017 at 12:27 pm

    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.

    Reply
    • WPBeginner Support says:
      Aug 16, 2017 at 12:35 am

      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.

      Reply
  20. Angela says:
    Aug 11, 2017 at 5:49 pm

    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?

    Reply
  21. Jen says:
    Aug 1, 2017 at 12:33 pm

    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?

    Reply
  22. John says:
    May 26, 2017 at 9:01 pm

    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.

    Reply
  23. Sarthak says:
    May 19, 2017 at 9:38 am

    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.)

    Reply
  24. George Beasley Jr says:
    Apr 8, 2017 at 1:44 am

    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?

    Reply
    • WPBeginner Support says:
      Apr 10, 2017 at 12:33 am

      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.

      Reply
  25. Frank says:
    Apr 5, 2017 at 9:31 pm

    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.

    Reply
    • Frank says:
      Apr 17, 2017 at 8:03 pm

      Anyone have any idea why I have this problem ?

      Thanks !

      Reply
  26. Riju says:
    Mar 31, 2017 at 8:54 pm

    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

    Reply
  27. Bamz says:
    Mar 30, 2017 at 6:35 pm

    Thank you very much. Please where can I paste Google AdSense code in this plugin, header or footer?

    Reply
  28. Riju says:
    Mar 29, 2017 at 8:55 pm

    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

    Reply
  29. echenze says:
    Mar 25, 2017 at 2:21 pm

    Hi, can this still be used to insert the code that one is given for verification of a Google Adsense account?

    Reply
    • WPBeginner Support says:
      Mar 25, 2017 at 9:04 pm

      Yes it can be used for that.

      Reply
  30. Samuel says:
    Mar 8, 2017 at 6:13 am

    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

    Reply
    • WPBeginner Support says:
      Mar 8, 2017 at 6:19 pm

      Hi Samuel,

      This issue has been fixed in version 1.4.1, please update the plugin.

      Reply
  31. Meaghan Nutt says:
    Feb 22, 2017 at 3:56 pm

    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!

    Reply
  32. raunak says:
    Jan 31, 2017 at 1:27 am

    hey thanks for this amazing plugin
    but could it work if i paste google verification code on the header

    Reply
  33. massive says:
    Jan 27, 2017 at 12:43 pm

    Thank you for this greate article, my question can I use this plugin to insert ad codes like ad codes of affiliates programs?

    Reply
  34. Rizwan Amjad says:
    Jan 22, 2017 at 5:38 am

    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.

    Reply
    • WPBeginner Support says:
      Jan 22, 2017 at 12:50 pm

      Hey Rizwan,

      Yes you can multiple code snippets on new lines by pressing enter button after pasting each snippet.

      Reply
      • Isabella says:
        Sep 29, 2017 at 7:11 pm

        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

        Reply
        • WPBeginner Support says:
          Sep 29, 2017 at 10:24 pm

          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.

  35. Paul says:
    Jan 19, 2017 at 1:15 pm

    Excellent video. Very clear and helpful. I am now subscribing to your channel.

    Reply
  36. dominion says:
    Jan 11, 2017 at 3:24 pm

    good day. without installing any wp theme,is there any way I can use my own theme. or template

    Reply
  37. gajendra says:
    Nov 30, 2016 at 1:30 am

    Superb Plugin….

    Reply
  38. Vladimír says:
    Nov 1, 2016 at 11:14 am

    This is grat plugin, I see it is more than one year without updates. Could you please update it?

    Vladimir

    Reply
  39. Lauren says:
    Jul 18, 2016 at 9:01 am

    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!

    Reply
    • WPBeginner Support says:
      Jul 19, 2016 at 1:02 pm

      You are welcome :)

      Reply
  40. nazanin says:
    Jul 9, 2016 at 3:38 am

    hi ,
    i want to add my logo from wp(dynamic logo)
    where is this plugins >?

    Reply
  41. khalid says:
    Jun 21, 2016 at 6:25 pm

    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.

    Reply
    • Suzanne Ball says:
      Apr 29, 2017 at 7:11 pm

      I get “403 Forbidden

      A potentially unsafe operation has been detected in your request to this site.”

      when I insert the google script

      Reply
  42. Rene Hedges says:
    May 20, 2016 at 6:22 am

    Thank you! Being very new to site building, and with no experience with working with coding, this was easy to follow!

    Reply
    • WPBeginner Support says:
      May 20, 2016 at 10:44 pm

      Glad you found it helpful. :)

      Reply
  43. haris says:
    Apr 11, 2016 at 12:12 am

    hi i am new in wp…….how to make database in wp and create table insertion etc….

    Reply
  44. Marcelo Guimaraes says:
    Feb 9, 2016 at 10:19 am

    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)?

    Reply
    • WPBeginner Support says:
      Feb 9, 2016 at 8:14 pm

      You are covering the entire site.

      Reply
  45. Luciferbui says:
    Nov 18, 2015 at 12:41 am

    Do you have html code or something, i need it to make my site faster
    No more plugin :)
    Thanks

    Reply
  46. Patrick Saad says:
    Oct 28, 2015 at 11:33 am

    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 !

    Reply
    • WPBeginner Support says:
      Oct 29, 2015 at 1:04 pm

      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.

      add_action( 'send_headers', 'add_header_xua' );
      function add_header_xua() {
      	header( 'X-UA-Compatible: IE=edge,chrome=1' );
      }
      
      Reply
  47. Conrad Hall says:
    Oct 26, 2015 at 11:23 am

    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.

    Reply
    • WPBeginner Support says:
      Oct 26, 2015 at 5:19 pm

      If your theme has a navigation menu in the footer area, then please see our guide how to add navigation menu in WordPress.

      Reply
  48. Richard Bauer says:
    Jul 21, 2015 at 12:18 am

    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

    Reply
  49. marke says:
    Mar 31, 2015 at 5:15 pm

    Same result from inserting in wp_head Hook in Genesis Simple Hooks? Worked for me.

    Reply
  50. WPBeginner Staff says:
    Dec 18, 2014 at 9:02 pm

    Yes it is.

    Reply
« 1 2

Leave a Reply Cancel reply

Thanks for choosing to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and your email address will NOT be published. Please Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.

Over 600,000+ Readers

Get fresh content from WPBeginner

Featured WordPress Plugin
OptinMonster
OptinMonster
Convert website visitors into email subscribers. Learn More »
How to Start a Blog How to Start a Blog
I need help with ...
Starting a
Blog
WordPress
Performance
WordPress
Security
WordPress
SEO
WordPress
Errors
Building an
Online Store
Useful WordPress Guides
    • 7 Best WordPress Backup Plugins Compared (Pros and Cons)
    • How to Fix the Error Establishing a Database Connection in WordPress
    • Why You Need a CDN for your WordPress Blog? [Infographic]
    • 25 Legit Ways to Make Money Online Blogging with WordPress
    • Self Hosted WordPress.org vs. Free WordPress.com [Infograph]
    • Free Recording: WordPress Workshop for Beginners
    • 24 Must Have WordPress Plugins for Business Websites
    • How to Properly Move Your Blog from WordPress.com to WordPress.org
    • 5 Best Contact Form Plugins for WordPress Compared
    • Which is the Best WordPress Popup Plugin? (Comparison)
    • Best WooCommerce Hosting in 2018 (Comparison)
    • How to Fix the Internal Server Error in WordPress
    • How to Install WordPress - Complete WordPress Installation Tutorial
    • Why You Should Start Building an Email List Right Away
    • How to Properly Move WordPress to a New Domain Without Losing SEO
    • How to Choose the Best WordPress Hosting for Your Website
    • How to Choose the Best Blogging Platform (Comparison)
    • WordPress Tutorials - 200+ Step by Step WordPress Tutorials
    • 5 Best WordPress Ecommerce Plugins Compared
    • 5 Best WordPress Membership Plugins (Compared)
    • 7 Best Email Marketing Services for Small Business (2018)
    • Which is the Best WordPress Slider? Performance + Quality Compared
    • The Truth About Shared WordPress Web Hosting
    • When Do You Really Need Managed WordPress Hosting?
    • 5 Best Drag and Drop WordPress Page Builders Compared
    • How to Switch from Blogger to WordPress without Losing Google Rankings
    • How to Properly Switch From Wix to WordPress (Step by Step)
    • How to Properly Move from Weebly to WordPress (Step by Step)
    • Do You Really Need a VPS? Best WordPress VPS Hosting Compared
    • How to Properly Move from Squarespace to WordPress
    • 5 Best VPN Services for WordPress Users (Compared)
    • HostGator Review - An Honest Look at Speed & Uptime (2018)
    • SiteGround Reviews from 1032 Users & Our Experts (2018)
    • Bluehost Review from Real Users + Performance Stats (2018)
    • How Much Does It Really Cost to Build a WordPress Website?
    • How to Start a Podcast with WordPress (Step by Step)
    • How to Choose the Best Domain Name (8 Tips and Tools)
    • How to Setup a Professional Email Address with Google Apps and Gmail
    • How to Install Google Analytics in WordPress for Beginners
    • How to Move WordPress to a New Host or Server With No Downtime
    • Why is WordPress Free? What are the Costs? What is the Catch?
    • How to Make a Website in 2018 – Step by Step Guide
Deals & Coupons (view all)
MaxCDN
MaxCDN Coupon
Get 25% off MaxCDN, the same service that we use to make our site super fast.
Array Themes Coupon
Array Themes Coupon
Get 15% off an entire Array Themes collection of beautiful magazine, photography and portfolio WordPress themes.
Featured In
About WPBeginner®

WPBeginner is a free WordPress resource site for Beginners. WPBeginner was founded in July 2009 by Syed Balkhi. The main goal of this site is to provide quality tips, tricks, hacks, and other WordPress resources that allows WordPress beginners to improve their site(s).

Site Links
  • About Us
  • Contact Us
  • FTC Disclosure
  • Privacy Policy
  • Terms of Service
  • Free Blog Setup
Our Sites
  • OptinMonster
  • MonsterInsights
  • WPForms
  • List25
  • Awesome Motive
  •  

Copyright © 2009 - 2018 WPBeginner LLC. All Rights Reserved. WPBeginner® is a registered trademark.

WordPress hosting by HostGator | WordPress CDN by MaxCDN | WordPress Security by Sucuri.