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 标识后插进內容。



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

处理计划方案 WordPress 5.2或更高版本号:


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