页眉&页脚代码

Description

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 Tools页眉&页脚代码 (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 Tools页眉&页脚代码, 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.

插件完美或者插件出错

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.

我需要您的支持

如果没有像你这样的用户的贡献,很难继续开发和支持这个以及我的其他免费插件。 如果您喜欢使用《页眉 & 页脚代码》并发现它很有用,请考虑捐款。 您的捐款将有助于鼓励和支持插件的持续开发和更好的用户支持。

特点

  • 为页眉页面部分设置站点范围的自定义内容(在</head>之前)
  • Set site-wide custom content for body section (after the <body>) – Requires WordPress 5.2!
  • 为页脚页面部分设置站点范围的自定义内容(在</body>之前)
  • [NEW in 1.2] Set homepage specific custom code for head, body and/or footer if Homepage mode is se to Blog Posts
  • 为页眉页面部分设置文章特定的自定义代码(在</head>之前)
  • Set article specific custom code for body section (after the <body>) – Requires WordPress 5.2!
  • 为页脚页面部分设置文章特定的自定义内容(在</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
  • 位于工具>下的网站范围部分 页眉 & 页脚代码
  • 并未翻译: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.

屏幕截图

  • 在插件搜索结果中的页眉 & 页脚代码框
  • Plugin Settings page (Site-wide, Homepage and Article Post Types)
  • 文章具体metabox(Article specific metabox)
  • 插入HEAD(页眉)部分的自定义代码示例(站点范围内附加了特定文章)
  • Example of custom code inserted to BODY section (site-wide with appended article specific)
  • 插入FOOTER(页脚)部分的自定义代码示例(站点范围内附加了特定文章)
  • Example of 页眉&页脚代码 column on Pages listing, to identify which pages have set custom code, which one and what mode is selected

Installation

与任何其他WordPress插件一样,安装此插件相当容易。

标准程序

  1. 转到插件添加新(插件)
  2. 搜索head footer code
  3. 输入搜索插件字段had footer code,然后按Enter键。
  4. 找到插件 页眉 & 页脚代码,然后点击立即安装按钮。
  5. 成功安装插件后,单击链接激活插件
  6. 访问工具页眉 & 页脚代码
  7. 将所需的代码添加到适当的部分。

FTP 程序

  1. 解压缩 head-footer-code.zip
  2. 将整个目录及其下的所有内容上传到/wp-content/plugins/目录。
  3. 通过 WordPress 的“插件”菜单以激活本插件。
  4. 访问工具页眉& 页脚代码设置链接)。
  5. 将所需的代码添加到适当的部分。

常见问题

为什么类似一个自定义代码插件?(Why another one custom code plugin?)

因为所有其他类似的插件都无法满足我的要求。 一般来说,它们具有太多功能或缺少我需要的功能。

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’ ) ) {
wp_body_open();
}“`

Reviews

2020年8月12日
The only feature this plugin lacks is the ability to add custom code to the home-page if the home-page is a blog type page (showing latest posts).
2020年5月18日
The plugin does exactly what it says. Thank you so much developers! 🙂
2020年3月20日
Very good plugin with syntax highlighting that helps a lot to organize your code
2020年1月22日
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.
2019年11月29日
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.
阅读所有的23评价

Contributors & Developers

“页眉&页脚代码” 是开源软件。 以下人员对此插件做出了贡献。

Contributors

“页眉&页脚代码” 已翻译成5 语言环境。 感谢译者的贡献。

将“页眉&页脚代码”翻译成您的语言。

Interested in development?

Browse the code, check out the SVN repository, or subscribe to the development log by RSS.

更新日志

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 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
  • 更新:截图

1.0.9.1

  • 修复:多站点WP的致命错误(感谢@kunzemarketing报告)
  • 改进:用于前端调试的DRI

1.0.9

  • 添加:特定于文章的部分的描述性帖子类型和描述
  • 添加:在FOOTER部分处理短代码的选项(站点范围和特定于文章的全局设置)
  • 更改:HEAD和FOOT的独立优先级,以便管理员可以为页眉和页脚选择不同的优先级
  • 在插件设置中添加:用于HEAD和FOOTER代码的CodeMirror代码编辑器
  • 添加:插件激活挂钩,以防止传统WP和/或PHP的致命错误
  • 改进:加载安全性

1.0.8

  • 测试与WordPress 5.1.1和PHP 7.2.15的兼容性
  • 更改:元框布局和行为选择器的类型
  • 更改:将Post元变换转换为OOP
  • 更改:GNU GPL许可证到v3
  • 添加:捆绑GNU GPLv3许可证到插件代码库
  • 更新:截图

1.0.7

  • 兼容性检查:针对WordPress 4.7.1进行了测试
  • 用户体验:在全局设置页面上添加右侧边栏,其中包含捐赠链接,常见问题解答,社区支持和插件评论页面。
  • UX:在全局设置和文章页面上为textareas设置等宽字体

1.0.6

  • 修复: PHP注意:尝试获取非对象的属性在\wp-content\plugins\head-footer-code\inc\front.php中第41行
  • 修复:如果内容之后的文章/页面模板有另一个WP循环查询(如最近在RHS侧栏中发布的WP Widget),则覆盖文章/页面的页脚内容。
  • 优化:如果不是单数或文章类型未启用,请避免阅读文章元数据
  • 在WordPress v4.5-alpha-36504和主题Twenty Sixteen v1.2-alpha上的多站点环境(主要和其他网络网站)中进行测试。

1.0.5

  • 增强:添加卸载例程以在删除插件时进行一些内务处理。
  • 增强:在调试注释中添加文章类型。
  • 自述文件:测试WordPress v4.4-beta1并更新兼容性。

1.0.4

  • 修复:PHP警告:in_array() 期望参数2为数组,给定字符串(在v1.0.3中引入)

1.0.3

  • 更改:为特定于页面的页眉/页脚代码创建甚至默认的WP文章类型postpage可选

1.0.2

  • 更改:如果在违反PayPal可接受使用政策的网站上使用插件,则替换PayPal捐款链接以防止帐户限制

1.0.1

  • 修复:PHP注意尝试获取非对象的属性
  • 优化:从可用中删除附件文章类型,以选择无需在附件上设置自定义页眉/页脚代码
  • 优化:设置代码清理

1.0.0

  • 初始发行。