How to add Header & Footer script code in WordPress
Updated On May 27, 2017 May 26, 2015 -Written ByFor more functionality and integration of third party services, we need to add their respective code to the website. Like, for Google Analytics setup on a WordPress website we need to add meta verification code in the header and javascript code in the footer. Similarly, code for other services like Facebook Like Box, YouTube Subscribe button, Pinterest integration has to be added.
No need to edit WordPress theme files to add code
Ideally, one would add such code by editing theme files like header.php, footer.php and so on. For an experienced user, this can be an ideal and easy routine. However, other users may end up messing core theme files and bringing whole website down. Fortunately, there is an excellent alternative to this problem.
Insert Headers and Footers makes this all easy and practical. After the install, goto Settings > Insert Headers and Footers section. There you can paste any script code in ‘scripts in header’ and ‘scripts in footer’ boxes to execute in header and footer areas respectively.
Besides the ease of use, all scripts remain there even when you change WordPress theme. In the manual method of editing theme files, you will lose all script codes when a WordPress theme is changed. For sure a must have, even for users changing themes on a regular basis.
Genesis: Header & Footer Script options
If you are a Genesis Framework user, then there is no need to manually edit theme files or even install the above plugin. Genesis has this feature in-built in the core.
Just goto Genesis > Themes Settings option. Then use ‘Header and Footer Scripts’ section for adding and executing any script code in header or footer section of WordPress website.
Updated article. Originally published on: Aug 23, 2013
Simple Scripts plugin is pretty handy. Luckily, I’m using Genesis Framework, so no additional plugin is needed.