Descrição
Head & Footer Code plugin helps you add custom code snippets (JavaScript, CSS, or HTML) to the page even if you are not a programmer. It could be within the <head>
(site verification code for various services, custom styles, meta or Webfont link), right after opening <body>
(pixel tracking, analytics or heatmap code) or just before closing </body>
tag.
Go to Tools → Head & Footer Code in WordPress Dashboard. Insert custom code to HEAD, BODY or FOOTER section (depending on what you have to do).
If your WordPress shows the latest blog posts on the homepage, you can also add specific code only for the homepage on Tools → Head & Footer Code (there will be section Head, body and footer code on Homepage in Blog Posts mode)
To insert custom code specific for individual article (post, page or custom post type), use article-specific Metabox while editing post/page/custom post type (check out Screenshots). There choose if that specific code appends to site-wide code defined on Tools → Head & Footer Code, or to replace it.
Since version 1.2.5 you can also define Category specific code on each individual category.
Other taxonomies (tag and custom taxonomy) do not have their specific code. Global code uses instead for them.
This magic is done by hooking to WordPress hooks wp_head
, wp_footer
and wp_body_open
.
Various code snippets are supported, including but not limited to:
- Google Analytics
- Google Tag Manager
- Google Ads Conversion
- Lite Analytics
- Facebook Pixel
- Hotjar
- FullStory
- Google site verification
- Bing site verification
- Yandex site verification
- Alexa site verification
Works or broken?
If Head & Footer Code does not work on your WordPress project, please let us know by raising a new support ticket in the Community Forum and describe what does not works and how to reproduce the issue. We will make sure to resolve the issue as soon as possible.
If you find Head & Footer Code useful for your project, please review plugin.
Features
- 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
- [NEW in 1.3.1] Toggle homepage specific custom code on paged Homepage in Blog Posts mode (page 2, 3, a nd so on)
- 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>
) - [NEW in 1.3.0] Set category specific custom code for head, body and/or footer of the page
- 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
totrue
, you’ll see site-wide and article specific entries in page source code wrapped to comments. - Multisite is supported.
- PHP 8.2 compatible!
Data stored in database
General settings (HEAD, BODY, FOOTER global code and priority, Homepage code and behaviour) saves in WordPress option auhfc_settings
.
Each post/page/custom post type specific HEAD, BODY and FOOTER code and behaviour saves to post meta _auhfc
.
Each category specific HEAD, BODY and FOOTER code and behaviour saves to taxonomy meta _auhfc
.
During the Uninstall process all these data has been deleted from the database.
In case you wish to reinstall plugin, DO NOT UNINSTALL IT although Deactivate, then delete the directory /wp-content/plugins-head-footer-code
and then reinstall plugin.
Permissions on Multisite WordPress
Feature
Super Admin
Administrator
Editor
Author
Contributor
Subscriber
Global
Y
Y
N
N
N
N
Article specific
Y
Y
Y
Y
N
N
Category specific
Y
Y
N
N
N
N
Imagens de tela
Head & Footer Code box in Plugin search results Plugin Settings page (Site-wide, Homepage and Article Post Types) Article specific metabox Example of custom code inserted to HEAD section (site-wide with appended article specific) Example of custom code inserted to BODY and FOOTER sections (site-wide with appended article specific) Category specific metabox Example of custom code inserted to HEAD section (site-wide with appended category specific) Example of custom code inserted to BODY and FOOTER section (site-wide with appended category specific) Example of Head & Footer Code column on Pages listing, to identify which pages have set custom code, which one and what mode is selected
Instalação
Installation of the Head & Footer Code is easy as any other WordPress plugin.
Standard procedure
- In WordPress Dashboard go to Plugins → Add New.
- Enter
head footer code
to the Search plugins… field and wait for the moment. - Locate Head & Footer Code and click the Install Now button.
- After successful installation, click the Activate button.
- Click Settings link for Head & Footer Code or visit the Tools → Head & Footer Code.
- Add the desired code to the target section.
FTP procedure
- Click on the Download button to get Head & Footer Code installation package.
- Unpack archive head-footer-code.zip on local computer.
- Upload the entire directory head-footer-code to the
/wp-content/plugins/
directory on your server. - In WordPress Dashboard go to Plugins → Installed Plugins and click the link Activate for the Head & Footer Code plugin.
- Click Settings link for Head & Footer Code or visit the Tools → Head & Footer Code.
- Add the desired code to the target section.
FAQ
-
It’s not a bug, it’s a security measure by WordPress Core.
If you wish to remove hinting errors for Administrator role, make sure you allow
unfiltered_html
capability for that role (Google is your friend). -
Is supported PHP code in code snippets?
-
As it’s a security risk, the Head & Footer Code does not process PHP code if entered into any plugin field (global or article specific).
Any content added to HFC fields is printed on the front-end as is.
-
I entered code to BODY section, but nothing outputs on front-end
-
This feature is implemented since WordPress version 5.2 and requires theme compatibility.
To make sure if theme you use supports 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’ ) ) {
wp_body_open();
}
`
Avaliações
Colaboradores e desenvolvedores
“Head & Footer Code” é um software com código aberto. As seguintes pessoas contribuíram para este plugin.
Colaboradores“Head & Footer Code” foi traduzido para 6 localizações. Agradecemos aos tradutores por suas contribuições.
Traduzir “Head & Footer Code” para o seu idioma.
Interessado no desenvolvimento?
Navegue pelo código, dê uma olhada no repositório SVN ou assine o registro de desenvolvimento via RSS.
Registro de alterações
1.3.2 (2023-06-02)
- Tested: on PHP 8.2.6 and WordPress 6.2.2 with Twenty Twenty-Three theme (Single and Multisite)
- Fixed: Deprecated and Warning notices in update.php on PHP 8.2.6
- Improve: Multisite support CodeMirror on Article and Category
1.3.1 (2023-03-18)
- Tested: on PHP 8.1.14/8.2.1 and WordPress 6.2-RC2 with Twenty Twenty-Three theme (Single and Multisite)
- Add: support do not add homepage in Blog Post related code on paged pages (2, 3, and so on)
- Add: CodeEditor on textareas in article Meta boxes
- Fix: Fatal error due to relocated plugin update file
- Cleanup: Remove donate button from settings page
- Improve: Security.
- Improve: Coding Standard.
1.3.0 (2022-05-08)
- Tested: on PHP 8.1.5 and WordPress 6.0-RC1 with Twenty Twenty-Two theme (Single and Multisite)
- Add: Support for Categotry specific code.
- Improve: Coding Standard.
- Improve: Important notes on settings page.
- Improve: README converted to MarkDown.
- Improve: Remove PayPal logo and load minified admin stylesheet.
1.2.4 (2021-10-15)
- Tested: on WordPress 5.8.1 and PHP 8.0.9 and 8.0.11
- Improve: clarify within article metabox on how replace behaviour for article-specific code works
- (2021-08-23) Improve: along to FOOTER, enable processing of shortcodes in HEAD and BODY (you has to enable this opetion per location)
1.2.3 (2021-07-19)
- Tested: on WordPress 5.8-RC4 and PHP 8.0.8
- (2021-05-04) Fix: Notice errors Trying to get property ‘post_type’ of non-object in inc/front.php (thanks to @tekgirlymama)
- Improve: DRY for getting post type.
1.2.2 (2021-04-24)
- Tested: on WordPress 5.7.1
- (2021-02-01) Fix: Noice errors in update script (thanks to @swinggraphics)
- Improve: wording on post/page listing
1.2.1
- Add: Head & Footer Code column to post/page/custom post type listing to show if/what article specific custom code is defined
- Fix: in_array() expects parameter 2 to be array, null given in head-footer-code/inc/front.php on line 46, 111, and 176
1.2
- Add: custom head, body and footer code for Homepage in Blog Posts mode.
- Fix: Code Editor broken in WordPress 5.5 release.
- Fix: Invalid requests while saving settings https://github.com/urosevic/head-footer-code/issues/1
- Improve: DRY for front-end conditions.
- Improve: translators tips for complex strings.
- Improve: all strings available to localize.
1.1.1
- Tested: on WordPress 5.4.1, 5.5-RC2-48768 with PHP 7.4.1
- Add: Video tutorial on how to install, configure and use Head & Footer Code plugin
1.1.0
- 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 toupdate_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
1.0.9.1
- Fix: Fatal Error on Multisite WP’s (thanks @kunzemarketing for reporting)
- Improve: DRI for front-end debugging
1.0.9
- 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
1.0.8
- 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
1.0.7
- 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
1.0.6
- 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.
1.0.5
- 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.
1.0.4
- Fix: PHP Warning: in_array() expects parameter 2 to be array, string given (introduced in v1.0.3)
1.0.3
- Change: Make even default WP post types
post
andpage
optional for page specific head/footer code
1.0.2
- Change: Replace PayPal donation links to prevent account limitations if plugin is used on website that violates PayPal’s Acceptable Use Policy
1.0.1
- 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
1.0.0
- Release inicial.