It may not be easy to locate tags. Therefore, you can locate them by pressing Control + F keys in the editor. Or, simply type “Head” to find it in the search bar. Following is an example demonstrating how I incorporated Google Tag Manager and Ahrefs Verification Code just above the tag:
Editing the footer is done in exactly the same manner as you did in the header. All you need is to select the footer.php file instead of header.php and you’re ready-to-go.
Once you have saved all changes, the last step you will have to take is to re-check whether your code was added to the header and footer files or not. To carry out this process, just go to your home and immediately view the source code. Or use the command + F key to locate the tag, and look at the right-side of your screen to ensure that you’ve added your code successfully.
If you think that this manual process is overwhelming and want a more easy solution, then go for a plugin.
What is the Best Plugin for Adding Header & Footer Scripts?
Generally, WordPress themes and frameworks come with built-in functionality for adding header and footer scripts. For example, the Genesis Framework can help you with header and footer scripts. It comes with a built-in editor to help you utilize full functionalities for any theme.
Use Insert Header and Footer plugin to ease up editing process:
Simply add code to the header/footer of your WordPress website. Plus, this plugin comes handy especially in third-party code integration, Google Analytics scripts, etc. Rest assured – this plugin does a better job in a few clicks.
Next, you’ll see ‘text fields’ where you can add scripts to the header, body and footer of your website. In the end, when you’re done, hit the ‘Save’ button.
You will need following things to optimize your endeavors:
- Custom Fields Feature to call the file from your post/pages.
Go to the Block editor, and click on three vertical dots (it will launch a drop-down menu), and then click ‘Options’:
Tick on the ‘Custom Fields’ in advanced panel in ‘Options’ (have a look at an image below):
So, you will see a space to add custom field under a post editor
This wasn’t bad at all was it? If it was a little, well we did tell you it is the most dreaded of all languages. But WordPress does make it easier.
If you still think it is beyond you, just let us know. Our experts will happily guide you through.