Head & Footer Code

Mô tả

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 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.

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>)
  • 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
  • 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.

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

Ảnh màn hình

  • Head & Footer Code box in Plugin search results
  • Site-wide settings page
  • Article specific metabox
  • Example of custom code inserted to HEAD section (site-wide with appended article specific)
  • Example of custom code inserted to BODY section (site-wide with appended article specific)
  • Example of custom code inserted to FOOTER section (site-wide with appended article specific)

Cài đặt

Installation of this plugin is fairly easy as any other WordPress plugin.

Standard procedure

  1. Go to PluginsAdd New.
  2. Search for head footer code.
  3. Enter to Search Plugin field had footer code and press Enter key.
  4. Locate plugin Head & Footer Code and click Install Now button.
  5. After successfully installed plugin click link Activate Plugin.
  6. Visit the ToolsHead & Footer Code.
  7. Add the desired code to proper section.

FTP procedure

  1. Unpack head-footer-code.zip
  2. Upload the whole directory and everything underneath to the /wp-content/plugins/ directory.
  3. Activate the plugin through the ‘Plugins’ menu in WordPress.
  4. Visit the ToolsHead & Footer Code (Settings link).
  5. Add the desired code to proper section.

Hỏi đáp

Why another one custom code plugin?

Because all other similar plugins could not satisfy my requirements. In general, they have too much features or lack some features I need.

I entered code to BODY section but nothing output on front-end

This feature is implemented since WordPress version 5.2, but also require compatibility theme. Make sure that your theme support wp_body_open hook.

Open in code editor header.php file from theme you use, and check if right after opening <BODY> tag there is following code (if it does not exists, add it or ask some developer to do that for you):
`if ( function_exists( ‘wp_body_open’ ) ) {

Đánh giá

18 Tháng Năm, 2020
The plugin does exactly what it says. Thank you so much developers! 🙂
20 Tháng Ba, 2020
Very good plugin with syntax highlighting that helps a lot to organize your code
22 Tháng Một, 2020
Excellent, très pratique car j'avais besoin d'un plugin pour placer une ligne de code dans l'en-tête mais dans des pages ou articles spécifique. J'espère que vous allez continuer à mettre à jour votre plugin.
29 Tháng Mười Một, 2019
this one takes all the credits for header/footer code plugins ever developed. all of them lack something or you have to pay money to get those extra features but this plugin really put every single plugin into shame. 500-star rating as just 5-star rating won't do them justice.
30 Tháng Mười, 2019
I have only needed to use the header part but it worked well, was easy to understand how (I like that it's under the Tools menu, too) and gives some control over positioning. I'm using Version 5.2.4
21 Tháng Tám, 2019
It works fine, I could put a script in a specific page's head as I needed. However, I could not place it right before (or even near) the </head> tag as I wished, even with the "priority" value set at 10.
Đọc tất cả 21 đánh giá

Người đóng góp & Lập trình viên

“Head & Footer Code” là mã nguồn mở. Những người sau đã đóng góp vào plugin này.

Những người đóng góp

“Head & Footer Code” đã được dịch qua 2 ngôn ngữ. Cảm ơn những người tham gia dịch vì đóng góp của họ.

Dịch “Head & Footer Code” sang ngôn ngữ của bạn.

Muốn tham gia phát triển?

Duyệt code, check out SVN repository, hoặc theo dõi nhật ký phát triển qua RSS.

Nhật ký thay đổi


  • Tested: on WordPress 5.4.1
  • Add: Video tutorial on how to install, configure and use Head & Footer Code plugin


  • Tested: on WordPress 5.1.4, 5.3.2 and 5.4-beta3 with PHP 7.2.15 and 7.3.7
  • Fix: Backslashes are removed on post/page update in article specific HEAD/BODY/FOOTER code reported by @asherber (update_post_meta pass key and value to update_metadata which expect them slashed key and value)
  • Add: Support for wp_body_open Body hook introduced in WordPress 5.2
  • Add: Backward compatibility for wp_body_open for older WordPress installations
  • Add: FAQ Instructions on how to implement support for wp_body_open to any theme
  • Update: Links and wording on plugin settings page
  • Update: Screenshots

  • Fix: Fatal Error on Multisite WP’s (thanks @kunzemarketing for reporting)
  • Improve: DRI for front-end debugging


  • Add: Descriptive post types and descriptions for article specific sections
  • Add: Option to process shortcodes in FOOTER section (global setting for site-wide and article specific)
  • Change: Separate priority for HEAD and FOOT so admin can choose different priorities for header and footer
  • Add: CodeMirror code editor for HEAD and FOOTER code in plugin settings
  • Add: Plugin activation hook to prevent fatal errors in case of legacy WP and/or PHP
  • Improve: Loading security


  • Test compatibility with WordPress 5.1.1 and PHP 7.2.15
  • Change: Meta boxes layout and type of behavior selector
  • Change: Convert Post metaboxes to OOP
  • Change: GNU GPL license to v3
  • Add: Bundle GNU GPLv3 license to plugin codebase
  • Update: Screenshots


  • Compatibility check: Tested for WordPress 4.7.1
  • UX: Add right hand sidebar on global settings page with links to donate, FAQ, Community support and plugin Reviews page.
  • UX: Set monospaced font for textareas on global settings and article pages


  • Fix: PHP Notice: Trying to get property of non-object in \wp-content\plugins\head-footer-code\inc\front.php on line 41.
  • Fix: Overwrite footer content for post/page if post/page template after content have another WP Loop query (like recent posts WP Widget in RHS sidebar).
  • Optimize: Avoid reading post meta if not singular or post type not enabled
  • Tested in Multisite environment (main and other network websites) on WordPress v4.5-alpha-36504 and theme Twenty Sixteen v1.2-alpha.


  • Enhance: Add uninstall routine to make some housekeeping on plugin removal.
  • Enhance: Add post type in debug comments.
  • Readme: Test on WordPress v4.4-beta1 and updated compatibility.


  • Fix: PHP Warning: in_array() expects parameter 2 to be array, string given (introduced in v1.0.3)


  • Change: Make even default WP post types post and page optional for page specific head/footer code


  • Change: Replace PayPal donation links to prevent account limitations if plugin is used on website that violates PayPal’s Acceptable Use Policy


  • Fix: PHP Notice Trying to get property of non-object
  • Optimize: Remove attachment post type from available to select as no reason to have custom head/footer code on attachments
  • Optimize: Settings code cleanup


  • Initial release.