There are many cases you need to insert some lines of code into the header or body of your WordPress template.
What you can place into those areas:
- Add a meta tag to verify an external service like Google Webmaster Tool.
- Add Google Analytics script.
- A JavaScript script or import a script library.
- Custom stylesheet.
Creating a module for that purpose is overkill, so we will use a plugin.
Table of Contents
Header and Footer Scripts
This plugin uses wp_head
and wp_footer
hooks and inserts your codes to the respective sections of the WordPress template.
![](https://www.tldevtech.com/wp-content/uploads/2020/09/wordpress_header_footer_script.jpg)
The setting page has 2 fields for the user to input scripts in the header or footer. It also offers an option to input a custom script to an individual post or page.
Insert Headers and Footers
Insert Headers and Footers is also a simple plugin to insert code like Google Analytics, custom CSS, Facebook Pixel, and more to header and footer sections.
![](https://www.tldevtech.com/wp-content/uploads/2020/09/Insert-Headers-and-Footers.jpg)
While the previous plugin allows script set in an individual post, this one allows the addition of content to beginning of the body tag.
It can be downloaded here.