Header & Footer
Most sites need a few bits of code on every page: an analytics tag, a site verification meta tag, a chat widget. Snipfire → Header & Footer is the quick way to add them. Paste the code into a box and click Save: no snippet settings to fill in.
The three boxes
| Box | Where the code goes | Typical use |
|---|---|---|
| Header | Inside <head> on every page |
Analytics, verification tags, fonts |
| Body | Right after <body> opens |
The "noscript" part of Google Tag Manager, chat widgets |
| Footer | Before </body> |
Scripts that can load last |
Paste the code exactly as the service gives it, <script> tags and all. Leave a box empty if you don't need it.
The Body box relies on the theme calling wp_body_open(). Almost all current themes do.
What they are underneath
Each box is an ordinary HTML snippet, so it gets everything a snippet gets:
- Checks when you save. PHP mixed into the code is checked, and switching a box on test-loads your site, like any snippet. If a box has a problem, the message after saving names the box.
- History. Every save is kept, so you can compare and restore earlier versions. See History.
- Crash protection. A box whose code causes an error is switched off and shows Switched off after an error.
- Conditions. Once a box has been saved, Open in the editor (conditions, history) opens its snippet in the editor. Add conditions there, for example to keep an analytics tag off staging sites.
The snippets live in the folder Header & Footer, as Header (Header & Footer), Body (Header & Footer) and Footer (Header & Footer). You'll see them in the editor's sidebar with your other snippets. With Git sync and in exports they travel like any other snippet, and the screen recognises them on the other site.
A box that's switched on shows On next to its name.
Switching a box off
Empty the box and click Save. Its snippet is switched off, not deleted, so its history is kept.
Saving the screen switches on every box that has code in it. If you switched a box's snippet off in the editor and want it to stay off, empty the box too.
Who can use it
Everyone who can create HTML snippets:
- Administrators.
- With Snipfire Pro, roles you gave CSS, JS and HTML (no PHP) or Full, including PHP in team access. People with CSS, JS and HTML access can't save a box that contains PHP.
People without that access don't see Header & Footer in the menu.
Coming from WPCode?
WPCode's global Header & Footer boxes are imported as three separate HTML snippets (Global header scripts, Global body scripts, Global footer scripts), not into these boxes. They work the same way. See Switch from WPCode.
Need more control?
For code that should appear only on some pages, at a certain priority, or somewhere else in the page, create an HTML snippet in the editor instead and choose its location. See Where snippets run.
Something unclear or missing? Tell us