Parameter | Details |
---|---|
$tag | (string) (Required) The name of the action to which the $function_to_add is hooked |
$function_to_add | (callable) (Required) The function which should be called when the action indicated by $tag is executed |
$priority | (int) (Optional) Default value: 10 Used to specify the order in which the functions associated with a particular action are executed. Lower numbers correspond with earlier execution, and functions with the same priority are executed in the order in which they were added to the action. |
$accepted_args | (int) (Optional) Default value: 1 The number of arguments the function accepts. |
The add_action()
function creates an Action Hook, associating a PHP function with a particular action "tag" or name. When the action is "triggered" by a call to do_action()
(or do_action_ref_array()
) with a specific tag, all functions "hooked" to that tag will be executed.
In most cases, this function should be used in a theme's functions.php
file or a plugin file - or another source file loaded by either.
This function is a part of the Plugin API