How do do_action and add_action work?

前端 未结 4 1376
执念已碎
执念已碎 2020-12-14 18:42

I am trying to find what exactly do_action and add_action works. I already examine with add_action but for do_action i am trying as new now. This what i tried.



        
4条回答
  •  隐瞒了意图╮
    2020-12-14 19:09

    //with do_action we create own tag(hook) use in wordpress Ex. Here I added 1 custom function to call this In add_action I added function name with any custom tag name With do_action(my custom tag name)

    function mywork()
    {
        echo "display my name";
    }
    
    add_action('mytag','mywork');
    
    do_action('mytag');
    

    ---add_action()---

    hook-specific hook that will affect by function()

     add_action( hook, **function**() )
    

    It will change functionality and behaviour of wordpress by Specific “hook” we can change it and functions method.

提交回复
热议问题