add_action( $hook, $function_to_add, $priority, $accepted_args );

I am unenable to understand what the code is used for? What are the inbuilt parameters and functions are mostly used in add_action?

From Codex:

Usage

add_action( $hook, $function_to_add, $priority, $accepted_args );

Parameters

$hook

(string) (required) The name of the action to which $function_to_add is hooked. (See Plugin API/Action Reference for a list of action hooks). Can also be the name of an action inside a theme or plugin file, or the special tag "all", in which case the function will be called for all hooks)

Default: None

$function_to_add

(callback) (required) The name of the function you wish to be hooked. Note: Only string-formatted syntaxes listed in the PHP documentation for the 'callback' type are valid.

Default: None

$priority

(int) (optional) 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.

Default: 10

$accepted_args

(int) (optional) The number of arguments the hooked function accepts. In WordPress 1.5.1+, hooked functions can take extra arguments that are set when the matching do_action() or apply_filters() call is run. For example, the action comment_id_not_found will pass any functions that hook onto it the ID of the requested comment.

Default: 1

The answer is written on the Codex page

what are the inbuilt parameters and functions are mostly used in add_action

Not sure what you are asking there, but if you mean how are they used? then take this example.

function my_title( $title ) {
    return "A new page title";
}
add_filter( 'wp_title', 'my_title', 10, 1 );

Somewhere before Wordpress creates the title for a page, it will call apply_filters('wp_title',$title);. The above function will hook into that call (meaning it will call your function) then your new function can change it's value.

Your Answer

 
discard

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.