Head & Footer Code

plugin banner

Easy add site-wide and/or article specific custom code to head and/or footer sections (before the </body>) by hooking to wp_head and wp_footer.

Author:Aleksandar Urosevic (profile at wordpress.org)
WordPress version required:4.9
WordPress version tested:5.6
Plugin version:1.2.1
Added to WordPress repository:14-08-2015
Last updated:31-12-2020
Rating, %:98
Rated by:28
Plugin URI:https://urosevic.net/wordpress/plugins/head-f...
Total downloads:267 594
Active installs:60 000+
plugin download
Click to start download

Let we say that you have been told to add some custom code (HTML, JavaScript or CSS style) to page’s <head> (like site verification code, custom styles, webfont link, etc), just before </body> or right after opening <body> (like pixel tracking, analytics code, heatmap code, etc), but you are not programmer. Then you can use Head & Footer Code to do that.

Simply go to Tools → Head & Footer Code in your website admin dashboard, and insert custom code to HEAD, BODY or FOOTER section (depending what you have to do).

If your WordPress show latest blog posts on homepage, you can also add specific code only for homepage on ToolsHead & Footer Code (there will be section Head, body and footer code on Homepage in Blog Posts mode)

If you have to insert some custom code specific for individual article (post, page, custom post type), then you can use Article specific metabox while you editing post/page/custom post type (check out Screenshots). There you can also set should that specific code be appended to site-wide code defined on ToolsHead & Footer Code, or should be overwritten.

Please note that taxonomies does not have own specific code but global code is added on those pages (category, tag and custom taxonomy listing, individual category, tags and custom taxonomies).

This magic is done by hooking to WordPress hooks wp_head, wp_footer and wp_body_open.

Works or broken?

Please, consider to vote for this plugin. When you vote for broken, be so kind and tell in the Forum what is broken. Maybe I might be able to fix it to make the plugin also work for you.

I need your support

It is very hard to continue development and support for this and my other free plugisn without contributions from users like you. If you enjoy using Head & Footer Code and find it useful, please consider making a donation. Your donation will help encourage and support the plugin’s continued development and better user support.


  • Set site-wide custom content for head page section (before the </head>)
  • Set site-wide custom content for body section (after the <body>) – Requires WordPress 5.2!
  • Set site-wide custom content for footer page section (before the </body>)
  • [NEW in 1.2] Set homepage specific custom code for head, body and/or footer if Homepage mode is se to Blog Posts
  • Set article specific custom code for head page section (before the </head>)
  • Set article specific custom code for body section (after the <body>) – Requires WordPress 5.2!
  • Set article specific custom content for footer page section (before the </body>)
  • Choose priority of printed custom code to head/body/footer sections (lower number mean far from </head> and </body> and closer to <body>, higher number means closer to </head> and </body> and farther to <body>)
  • Choose which post types will have enabled article specific head/body/footer fields
  • Choose should article specific head/body/footer code be appended to site-wide code, or will replace site-wide code
  • [NEW in 1.2.1] View on Posts/Pages/Custom Post Types listing if article has defined any article specific custom code
  • Site-wide section located under Tools > Head & Footer Code
  • If you have set WP_DEBUG constant in wp-config.php to true, you’ll see site-wide and article specific entries in page source code wrapped to comments.
  • Multisite is supported.

General settings, including HEAD, BODY, FOOTER global code and priority, and also homepage code and behavior have been saved to WordPress option auhfc_settings.
Each post/page/custom post type specific HEAD, BODY and FOOTER code and behavior have been saved to post meta _auhfc.
On plugin uninstall these data is also deleted from database.