WordPress hook directly after body tag

后端 未结 9 941
野性不改
野性不改 2020-12-14 16:39

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 h

9条回答
  •  鱼传尺愫
    2020-12-14 16:51

    WordPress 5.2 or newer:

    Use the wp_body_open 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: http://adambrown.info/p/wp_hooks/

提交回复
热议问题