There are times when you might need to add custom code to your WordPress site’s header (head), body, or footer. A good example would be with your favicon. We always recommend loading your favicon from your CDN, and with most themes, you will need to manually specify this.
On our site, we load the following in our header.
<link rel="icon" href="https://cdn.perfmatters.io/wp-content/uploads/2017/08/favicon.png" type="image/x-icon" />
With the Perfmatters plugin, you can easily drop any custom code into both your header, body, and footer.
What Type of Code Is Accepted?
The following boxes print out code directly on the front end, so it needs to be valid HTML. This could include inline CSS inside <style>
tags or inline JS inside <script>
tags. You could also load a JS or CSS file.
The boxes don’t accept server-side languages, such as PHP. For adding custom PHP code, we always recommend the Code Snippets plugin.
Add Code to WordPress Header
You can add code to your WordPress header by going to “Settings → Perfmatters → Extras” in your WordPress admin dashboard.
Scroll down to “Add Header Code.”

Code added here will be printed in the <head> </head>
section on every page of your website.
Add Code to WordPress Body
You can add code to your WordPress body by going to “Settings → Perfmatters → Extras” in your WordPress admin dashboard.
Scroll down to “Add Body Code.”

Code added here will be printed below the opening <body>
tag on every page of your website.
Note: The above box is only supported and will only show on WordPress 5.2 or higher.
Add Code to WordPress Footer
You can add code to your WordPress footer by going to “Settings → Perfmatters → Extras” in your WordPress admin dashboard.
Scroll down to “Add Footer Code.”

Code added here will be printed above the closing </body>
tag on every page of your website.