WordPress在行为主体标识后立即钩

I'm having problems finding the right hook to use for my plugin. I'm trying to add a message to the top of each page by having my plugin add a function. What's the best hook to use? I want to insert content right after the body tag.


The linked was closed as this feature was added in WordPress 5.2. You will find the Developer notes for this feature here (requires JavaScript enabled to display):

I will not update the "correct answer" to one that mentions 5.2 for historical reasons, but rest assured that I'm aware and that the built-in hook is the correct one to use.

处理计划方案WordPress 5.2 or newer:

Use the hook.

WordPress 5.1 or older:

That's kinda difficult... Most themes don't have any hooks in that area. You could hook a javascript/html solution into wp_footer and display it at the top of the page... sort of how Stack Overflow does it, or how Twitter does their notifications.

This is the best reference for all the hooks included in WordPress:


我在找寻可用于我的软件的钩子时遇到了难题。我正在尝试根据让我的软件加上作用来在每页顶部加上1条信息。最好是应用哪样钩子?我想在 body 标识后插进內容。





编写:我了解如今早已3年了,但这是1张的门票任何有兴趣爱好的人:





编写:2019年7月31日



连接的已关掉,由于该作用已加上到WordPress 5.2。您能够在此处寻找此作用的开发设计人员表明(必须开启JavaScript才可以显示信息):





出于历史时间缘故,我不容易将正确回答升级为提到5.2的回答,但请安心,我了解而且内嵌挂钩是应用的正确回答。
处理计划方案 WordPress 5.2或更高版本号:

应用钩子。


WordPress 5.1或更早版本号:
有点艰难...大多数数主题在该地区沒有任何关系。您能够将javascript / html处理计划方案联接到 wp_footer 并将其显示信息在网页页面顶部...相近于Stack Overflow的完成方法,或Twitter怎样开展其通告。


这是WordPress中包括的全部挂钩的最好参照: