php - can I pass arguments to my function through add_action? -


Can I do something like this? To argue my function? I have already studied but did not understand how to do it. For the passage of two arguments, the exact syntax will look like how text & amp; Integer logic .

  function recent_post_b_other ($ author, $ number_of_posts) {some commands; } Add_action ('thesis_hook_before_post', 'recent_post_by_author', 10, 'authors, 2')  

UPDATE

This is done in any way but how? : -)

instead of:

  add_action ('thesis_hook_before_post' , 'Recent_post_by_author', 10, 'authors, 2')  

should be:

  add_action ('thesis_hook_before_post', 'recent_post_by_author', 10, 2)  

... where there is a number of 2 arguments and 10 is the priority in which the function will be executed. You do not list your arguments in add_action. It initially slipped me into your function then looks like this:

  function function_name ($ arg1, $ arg2) {/ * do stuff here} / />  

Both add_action and function functions go into the FPP and you specify your arguments in the template file (for example, page.php), such as with do_action: < / P>

  do_action ('name-of-action', $ arg1, $ Arg2);  

Hope it helps.


Comments