This question might be wrong, I am not sure about it. Because I am not clear on this.
I know add_action
it is used to to hook our function to the specified function. For example add_action('wp_head'.'myfunc');
now what ever code in myfunc
will be executed in the wp_head()
. This is clear but i am having doubt in do_action
what it does?
I think it is used to create our own hook like already available hooks(wp_head,wp_footer,..etc) If i am correct can anyone show me a simple understandable answer with simple example.
I have tried the difference in internet but all are pointing to difference between add_action and add_filter. I don't want to go there because first i want to clarify this and then I’ll move there.
Can anybody help me?
EDIT after Question POST
function custom_register()
{
echo '<script>jQuery(document).ready(function(){alert("Learning Hooks");});</script>';
}
do_action('custom');
add_action('custom','custom_register');
I tried this in plugin but i didn't get the alert message.
But when i hook the same function with wp_head
then it is working fine
/******************working****************/
add_action('wp_head','custom_register');
do_action('custom');
after you registered the callback? And make sure jQuery is loaded.wp_head
it is working fine but not with thecustom