Adding code to the headerfooter
Insert Headers and Footers Plugin
A tip when adding code/script in the theme editor and header/footer
Sometimes during the training, we find we need to add some background code or a script to the header or footer of our website theme.
I've found it very easy to use the "insert header and footers" plugin. This makes it very easy to insert the code or scipts needed.
A script code will start with
<script......
and end wilth </script
Everything between those tags is the code or script.
You can learn more about the script HTML CODE here and more HERE
Sometimes you will find that a description is added for you as a comment before the start of the script.
<!-- This is a comment. Comments are not displayed in the browser -->
example:
<!-- Global site tag(gtat.js) - Google analytics -->
<!-- COMMENT added -->
The <!-- tells us the text is not part of a script but only a comment and is not to be read and executed
The --> This ends the comment part of the code
You can learn more about the comment HTML CODE HERE
But to remind yourself of what the code is there for, you can add a description above where the code or script starts.
EXAMPLE: This is the script I inserted when setting my site up for GA to add my unique ID:
<!-- Global site tag (gtag.js) - Google Analytics --> (this is the comment)
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-54074243-10"></script> (this is the script)
TIP, when adding a new script to the header/footer, add a couple of blank lines between the scripts so you can more easily tell where they start and stop.
Recent Comments
21
Can be a little bit tricky at times will keep the plugin in mind for those moments. Regards Shane.
Hi Shirley, thank you very much for the information. Much appreciated. Will this work for adding affiliate links also
No. Affiliate links go within the BODY SECTION (which is the part you create your blog text in) you get the affiliate links from the merchant's website using the method they instruct you to get them.
Thanks Shirley...I have forgotten some of the coding in html and this is a good reminder of it.
It’s been such a long time since I used it.
Bob
See more comments
Can you use this plugin with ANY theme?
Yes.