“Where do I put code in the header in WordPress?”
I get this question almost every week! There are quite a few common marketing tools that make you paste code in the header of your page or your website. Google Analytics, Facebook Ads, and Amazon Affiliates just to name a few. If you’re not a very techie person, this point in your process can throw you for a serious loop. Some WordPress themes have a place in the theme options marked for header code. But your theme doesn’t have it, you might need a plugin.
Insert Headers and Footers plugin by WP Beginner
This is a very light plugin that just does one thing. Download it from the WordPress.org repository and install it through your WordPress dashboard. Under Settings>Insert Headers and Footers you’ll find two entry fields. The header field is for code that should be loaded as soon as the page begins to load. The Footer field is for code that should be loaded last on the page.
Most of the time you’ll put the code from your tool in the Header field so it’s loaded first when the page comes up in the reader’s browser.
Plugin or Theme Fields – Which is Better?
Some theme developers purposely don’t include the Header and Footer script fields in their themes. There are a couple of reasons for this. First, they don’t want to be responsible for code in those fields that doesn’t play nice with their theme.
A second (and better) reason, is that keeping the extra code in a plugin gives you more flexibility to change your theme. If all of the code were entered through your theme, it would disappear when you redesigned your site. And since some of us (yes, I admit it) tend to redesign our websites multiple times a year… well, you can see the issue. Having the code in the plugin means it will stay in place and working no matter how many times I change my theme.