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
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
headof your blog.
- Paste your code.
- Make sure button at top, Enable header code, is enabled.
Adding a script to the header or footer of your WordPress website is easy to do with the free Insert Headers and Footers plugin.
Have you used the Insert Headers and Footers plugin? Or have you found another method to add code to the header or footer?