In addition to being an organizer for two WordPress meetup groups (Metro Detroit WordPress and West Metro Detroit WordPress), I regularly answer questions and give help on several online WordPress groups.
Last week, one of the group members asked:
Someone wants me to put some script code in the header of every page. Is this possible with WordPress?
Another member replied that it could be done by editing the header of the child theme.
But I knew another non-code option using a plugin that would make it easier to add a script to the header.
I shared my answer, pointing to the plugin.
And I explained that if the site was built with a framework or page builder, the steps were a bit different.
Read on to learn how you can add code in the header or footer of every page on your WordPress site.
Insert Headers and Footers
Using the Insert Headers and Footers plugin allows you to insert scripts to your header and footer in one place.
No more trying to figure out where you added a script for a plugin and no need to edit theme files.
Which means the scripts you add with the plugin won’t get deleted when you change themes. Nice!
The plugin is free and offers an easy to use interface for you to add your scripts. You can use it to add Google Analytics code, Google AdSense, or any other type of script or HTML.
Why I Like It
When you see a plugin with over 600,000 active installations, you know you’ve found a useful plugin!
Here are a few more reasons I like Insert Headers and Footers:
- Constantly maintained and updated
- Straightforward and easy to use
- Great reviews from users
How the Plugin Works
Once the Insert Headers and Footers plugin is installed and activated, you’ll find a new option has been added to your Settings.
To add script or code to your site, select Settings > Insert Headings and Footers.
Here’s the screenshot showing you the interface for adding scripts to headings or footers:
Very simple interface!
Site Built with Framework or Page Builder
As I mentioned earlier, if your site was built with a framework (like Genesis from StudioPress) or page builder (like Divi from Elegant Themes), the steps are a bit different.
Both Genesis and Divi include options to add code to your header or footer. You won’t need a plugin to do it.
If you’re using the Genesis framework, there are two options to add scripts, from the Genesis Theme Options or the Customizer.
I find it easier to make the changes in Theme Options.
From the Genesis menu in your Dashboard, select Theme Options, and add your script to either the header or footer textarea.
For anyone using Divi, the steps are similar. From the Divi menu in your Dashboard, select Theme Options:
- Select the Integration tab.
- Scroll to field labeled Add code to the
head
of your blog. - Paste your code.
- Make sure button at top, Enable header code, is enabled.
Summary
Adding a script to the header or footer of your WordPress website is easy to do with the free Insert Headers and Footers plugin.
It’s quick to set up, allowing you to insert HTML or JavaScript code.
Have you used the Insert Headers and Footers plugin? Or have you found another method to add code to the header or footer?
I got all excited the other day when I saw something about Insert Header and Footer. Since I wanted to use Google Analytics code in my header, I installed the plugin. Then I discovered that the line of code it inserts goes at the END of the head. I couldn’t find a way to make the inserted code go in at the first in the head. Other than that issue, it’s a very nice plugin.
Hi Virginia,
Thanks for stopping by! Glad you found Insert Headers and Footers plugin. I like the plugin because it keeps your code intact when you change themes.
Sure, lots of themes offer the same functionality in their “Theme Options”, but that will be gone when you change themes.
I haven’t heard of any way to add it to the beginning of the head, have you left a comment in support section for the plugin?