WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Why, when I want to use

add_filter( 'author_link', 'foo', 10, 3 );
function foo ( $link, $author_id, $author_nicename ) {}

I have to use 3 required parametres? Why cant I do this:

add_filter( 'author_link', 'foo' );
function foo ( $author_id ) {}

If you can, please give me some literature about this.

PS beginner in WP.

share|improve this question
up vote 1 down vote accepted

You don't have to specify number of arguments, in which case it will default to one.

Essentially this argument gives you control on how many arguments hook will pass to function, which matters in few too many situations to come up with generic explanation.

In a nutshell if hook can pass N arguments, your options are:

  • pass 1 argument (default)
  • pass <=N arguments by specifying number
  • do not pass any arguments by specifying 0 (rare, but highly useful at times)

Note that you cannot change order of arguments passed, if you need Nth you will need to pass as many and then ignore unwanted ones in your function (which only makes sense in few hooks, because first argument tends to be meaningful one, rarely second).

share|improve this answer

If you require only the first argument to fulfil your job then it is not necessary to specify the number of arguments. The number of arguments need to be specified if the function you are writing might need the extra information (arguments).

The first argument is actually what you should be returning back in your function. The other arguments act as helpers to get the desired output.

share|improve this answer
and if I need only second argument? – Reshat Belyalov May 31 '12 at 11:25
Then you could try this maybe add_filter( 'author_link', 'foo', 10, 2 ); function foo ( $link, $author_id ) {} But you will have to use the first argument also. Have not tested if the above thing would work. It should work though. – Joshua Abenazer May 31 '12 at 11:30
Yes, it works with two args. Thanks. But where can I find info about this requirements? – Reshat Belyalov May 31 '12 at 11:32

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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