How to run a hook action when header load in wordpress blog?

丶灬走出姿态 提交于 2019-12-07 16:48:30

问题


Am woking on an error plugin. I want to generate some error or success msgs when header loads in WordPress blog site.

like as:

if(is header load)
{
  //run a action hook here
  //print success or error msgs through hook function
}

suggest a hook action to display msgs when header load.


回答1:


Below code might help. You can put this code in the functions.php in your theme folder.

                function load_me_on_header()
            {
               // do something here ... like show error message.
            }

            add_action('wp_head','load_me_on_header');



回答2:


You can also use the add_filter() function the same way. Filters are more suiteble when content processing is invold.



来源:https://stackoverflow.com/questions/10315647/how-to-run-a-hook-action-when-header-load-in-wordpress-blog

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!