Insert Header Footer & Body Code is a lightweight WordPress plugin for inserting custom header, body, and footer code snippets, structured data, schema markup, analytics scripts, verification tags, and body classes without editing theme files.
The plugin is useful for SEO, AEO (Answer Engine Optimization), GEO (Generative Engine Optimization), Google Tag Manager, analytics integrations, JSON-LD schema insertion, custom tracking scripts, and AI search optimization workflows.
This plugin can be used to:
- insert SEO verification tags
- add JSON-LD structured data
- inject schema markup
- add Google Analytics and Google Tag Manager scripts
- manage custom tracking snippets
- support AI search and generative engine optimization workflows
- customize body classes for advanced CSS targeting
This repository is prepared for a public first release and ongoing maintenance as an open-source WordPress plugin project.
This plugin was originally built with advanced conditional insertion controls and body class management in mind. It gives site administrators a practical way to:
- insert site-wide header, body, and footer code
- add conditional code to specific posts, pages, and custom post types
- add conditional code to taxonomy term archive views
- attach custom body classes to selected items and terms
That makes it useful for analytics snippets, verification tags, structured data, CSS targeting, campaign-specific scripts, and similar controlled front-end changes.
- Global header, body, and footer code fields
- Conditional post type enablement for per-item code fields
- Conditional post type enablement for per-item custom body class fields
- Conditional taxonomy enablement for term-level code fields
- Conditional taxonomy enablement for term-level custom body class fields
- Native WordPress settings screens, meta boxes, and term fields
- Body class sanitization into valid CSS class tokens
- Raw snippet handling reserved for users with the
unfiltered_htmlcapability
- Download a clean release ZIP.
- In WordPress admin, go to
Plugins > Add New > Upload Plugin. - Upload the ZIP and activate the plugin.
- Open
Settings > Header Footer Body Code.
- Clone this repository.
- Place the plugin folder inside your local WordPress
wp-content/plugins/directory, or symlink it there if you prefer. - Activate the plugin in your local WordPress installation.
- Run tests locally before making changes.
The plugin is intentionally kept lightweight and WordPress-native.
Development-oriented files may exist in this source repository, including:
tests/composer.jsoncomposer.lockphpunit.xml.dist.phpcs.xml.dist
These files help maintain the project, but they are not required in the end-user plugin ZIP.
PHPUnit is configured for lightweight utility and settings tests.
Requirement:
- Composer installed locally
If you are already inside the plugin directory:
composer install
vendor\bin\phpunit --configuration phpunit.xml.distOr:
composer install
composer testIf you want to run the commands from another location:
Set-Location "path\to\insert-header-footer-body-code"
composer install
vendor\bin\phpunit --configuration phpunit.xml.distOr:
Set-Location "path\to\insert-header-footer-body-code"
composer install
composer testcd /path/to/insert-header-footer-body-code
composer install
vendor/bin/phpunit --configuration phpunit.xml.distThis GitHub repository is intended to be development-friendly.
For a clean end-user plugin ZIP, include only the runtime plugin files such as:
insert-header-footer-body-code.phpreadme.txtuninstall.phpincludes/languages/
Exclude development files from the release ZIP, including:
tests/composer.jsoncomposer.lockphpunit.xml.dist.phpcs.xml.distvendor/- local logs, caches, and temporary build files
See RELEASE.md for a concise release checklist.
This project is licensed under the GNU General Public License, version 2.0 or later.
See LICENSE for details.