[WordPress] 外掛分享: Head & Footer Code

WordPress 外掛 Head & Footer Code 的封面圖片。

前言介紹

  • 這款 WordPress 外掛「Head & Footer Code」是 2015-08-13 上架。
  • 目前有 100000 個安裝啟用數。
  • 上一次更新是 2025-04-30,距離現在已有 3 天。
  • 外掛最低要求 WordPress 4.9 以上版本才可以安裝。
  • 外掛要求網站主機運作至少需要 PHP 版本 5.5 以上。
  • 有 51 人給過評分。
  • 論壇上目前有 5 個提問,問題解答率 80% ,不低,算是個很有心解決問題的開發者團隊了!

外掛協作開發者

urkekg | techwebux |

外掛標籤

body | code | head | footer | script |

內容簡介

Head & Footer Code 插件可以讓你在不是開發人員的情況下,添加自定義代碼片段(JavaScript、CSS 或 HTML)到網頁中。您可以將代碼放置在 (各種服務的站點驗證代碼,自定義樣式,meta 或 Webfont 連結)、在開始 後(像素跟踪、分析或熱點代碼)或者網頁即將結束前的 标签之前。

在 WordPress 儀表板中,前往「工具」>「Head & Footer Code」。將自定義代碼插入到 HEAD、BODY 或 FOOTER 部分(取決於您需要做什麼)。

如果您的 WordPress 在首頁顯示最新的博客文章,您還可以在「工具」>「Head & Footer Code」中為首頁添加特定代碼(博客文章模式下主頁面頭部、主頁面體和尾部代碼部分會有對應的區域)

要插入特定文章(文章、頁面或自定義文章類型)的自定義代碼,請在編輯文章/頁面/自定義文章類型時使用文章特定 MetaBox(請查看「截圖」)。

自定義代碼將根據選擇的選項添加到在「工具」>「Head & Footer Code」中定義的網站範圍代碼中,或者取代它。

從版本 1.2.5 開始,您還可以在每個個別類別上定義特定代碼,
其他分類法(標籤和自定義分類法)沒有其特定代碼。全球代碼代替了它們。

此功能是通過掛鉤到 WordPress 鉤子 wp_head、wp_footer 和 wp_body_open 實現的。

此外,支持各種代碼片段,包括但不限於:

Google Analytics
Google Tag Manager
Google Ads Conversion
Facebook Pixel
Hotjar
FullStory
Google 站點驗證
Bing 站點驗證
Yandex 站點驗證
Alexa 站點驗證

正常運作或遇到問題?

如果 Head & Footer Code 在您的 WordPress 構建中未正常使用,請通過在 社區論壇 中提出新的支援工單,描述問題及如何重現問題。我們會盡快解決問題。

如果您認為 Head & Footer Code 對您的項目有用,請評論插件。

功能

為網頁头部部分( 之前)設置全站自定義內容
為網頁 BODY 部分( 後面)設置全站自定義內容-需要 WordPress 5.2!
為網頁底部部分( 之前)設置全站自定義內容
[新功能 1.2 中] 如果主頁模式設置為博客文章,則為首頁設置特定的自定義代碼,支援頁面頭部、主要體和/或頁角的代碼部分
為網頁头部部分( 之前)設置特定文章的自定義代碼
為網頁 BODY 部分( 之後)設置特定文章的自定義代碼-需要 WordPress 5.2!
為網頁底部部分( 之前)設置特定文章的自定義代碼
[新功能 1.3.0] 為頁面頭部部分、主體和/或頁角的特定分類設置自定義代碼
選擇要在头部、主体或页脚部分打印的自定義代码的优先级(数字越小代表离 和 更远,离 越近。数字越大,代表靠近 和 )

原文外掛簡介

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

(site verification code for various services, custom styles, meta or Webfont link), right after opening (pixel tracking, analytics or heatmap code) or just before closing 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).
All magic is done by hooking to WordPress hooks wp_head, wp_footer and wp_body_open.

💡 Trial Head & Footer Code plugin on a free dummy website before you add it on your project: Test It Now!

Various code snippets are supported, including but not limited to:

Google Analytics 4
Google Tag Manager
Google Ads Conversion
Lite Analytics
Facebook/Meta Pixel
Hotjar
FullStory
Google site verification
Bing site verification
Yandex site verification
Alexa site verification

Homepage in Blog Posts mode
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)
Article specific code
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.
Category specific code
You can also define a Category specific code on each individual category.
Other taxonomies (tag and custom taxonomy) do not have available their specific code, but for them a Global code is used instead.
Video guide

Do you need our support?
If Head & Footer Code does not work on your 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

Multisite and PHP 8.3 compatible!
Set site-wide custom content for:

head page section (before the )
body section (after the

) – Requires WordPress 5.2!
footer page section (before the )

Homepage in Blog Posts mode:

set homepage specific custom code for head, body and/or footer
toggle homepage specific custom code on paged Homepage (page 2, 3, a nd so on)

Set article specific custom code for:

head page section (before the )
body section (after the

) – Requires WordPress 5.2!
footer page section (before the )

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 and

and closer to

, higher number means closer to and

and farther to

)
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
View on Posts/Pages/Custom Post Types listing if article has defined any article specific custom code
Site-wide section is 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.
[NEW] allow unprivileged user roles Editor and Author to manage article-specific code on single site and multisite (disabled by default)

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

Access to Global: only Super Admin and Administrator
Access to Article specific: Super Admin, Administrator; optional: Editor and Author
Access to Category specific: only Super Admin and Administrator

各版本下載點

(建議使用方法二,確保安裝的版本符合當前運作的 WordPress 環境。


1.2 | 1.0.8 | 1.0.9 | 1.1.0 | 1.1.1 | 1.2.1 | 1.2.2 | 1.2.3 | 1.2.4 | 1.3.0 | 1.3.1 | 1.3.2 | 1.3.3 | 1.3.4 | 1.3.5 | 1.3.6 | 1.3.7 | 1.4.0 | 1.4.1 | 1.4.2 | 1.4.3 | trunk | 1.0.9.1 |

延伸相關外掛(你可能也想知道)