I am reading the source of a plugin (gallery to slideshow plugin) to make it behave like i want and it is using an action

add_action( 'the_posts', array( &$this, 'have_gallery' ), 10, 1 );

I want to know what those extra parameters (10,1) mean but i cant find the documentation of this action. Please help

  • 2
    It's helpful to search Google with the function name: add_action WordPress. Most functions are pretty well documented in the Codex. Commented Feb 27, 2012 at 15:03

2 Answers 2


those parameters aren't unique to the_posts, they're parameters for the add_action() function

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

the 10 is just the default priority and 1 is the default number of accepted arguments. since they're both default, you don't really need either.


  • Ok nice, But what does this hook do?
    – Dr Deo
    Commented Feb 27, 2012 at 15:08
  • did you check the codex? add_action adds a function to a wordpress action. so your plugin is telling wordpress to run its 'have_gallery' function when wordpress runs the the_posts() action Commented Feb 27, 2012 at 16:52
  • By the way, if you check the source for add_action, you'll see it uses ksort on the plugin event array per each event. This means that negative values are possible and will sort higher than zero. PHP5 will let you create a key with the max negative value of -1410065407. So, if you hook the init event with that priority, it will likely be the first event ever run. Just remember that if you don't need that early of a priority, go with something in the 10+ range. In my case, I needed it to build a plugin to block bad spiders.
    – Volomike
    Commented May 2, 2012 at 6:59

This is rather add_action() related.

   'the_posts', //$tag
   array( &$this, 'have_gallery' ), //$function_to_add
   10, //$priority - run priority, when to execute given action 
   1 //$accepted_args - number of accepted arguments, one in this case

10 means default run priority and 1 stands for one argument that this function takes.

  • Thanks for the Quick response. But i wonder how on earth the plugin writer came across this hook and used it without documentation.
    – Dr Deo
    Commented Feb 27, 2012 at 15:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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