From the codex, regarding filter hooks:

applied to the the output of bloginfo("url"), bloginfo("directory") and bloginfo("home") before returning the information.

Is there a way I can specify that a bit more precise? So that I can hook something only to bloginfo("url") for example?

1 Answer 1


You can access that, using the additional variable in the Filter Functions.

The Filter bloginfo_url uses the $show parameter (the parameter you use when calling bloginfo) and passes it to apply_filters.

So hooking into bloginfo_url should be no problem, you just have to make a switch inside the function, and it only applies to e.g. url .

This would be the Code for you:

add_filter('bloginfo_url', 'f711_bloginfo_url_filter', 10, 2 );

It tells you where you hook into, the callback function, the priority in which it is applied compared to other filters, and the number of arguments that can be passed to the function. This is your important part, as 1 is the standard value.

In the Callback Function:

function f711_bloginfo_url_filter( $output, $show ) {

    if ( $show == 'url' ) {
        $output = "this";//whatever you want to do with it

    return $output;

  • Super cool thank you! Do you have a link where this is documented? In the Codex page for bloginfo $show is mentioned and in the page for add_filter the integer is mentioned, but how do I know exactly which int targets what property?
    – Sven
    Commented Feb 19, 2013 at 17:30
  • If it is not documented on the Codex, you may have to look into the Sourcecode for the specific filter. There you can see how much Arguments are passed on, and this should determine the value of the second integer you use to hook your filter function. Afterwards they are used in the same order as they are passed to the filter. If you look at general-template.php in the wp-includes you can find this filter, and I'm sure you understand better what I am talking about ;)
    – fischi
    Commented Feb 19, 2013 at 17:39
  • Sorry to bother you again, but I can't find it in that file, although I think I know what you mean. Is it that function at line 405? core.trac.wordpress.org/browser/tags/3.5.1/wp-includes/… I just want to really understand how this works, because for example I can't hook that function into home_url or site_urlbecause I don't know the parameters.
    – Sven
    Commented Feb 19, 2013 at 18:05
  • No problem. This is the right file, and you are in the right function, but you have to look at the lines where the filters are applied. Line 491 is the correct one, and of course 493. Here you can see that the filter for bloginfo_url is applied, with the two parameters $output and $show, the latter being defined before (starting at line 405). Everything clear so far? Don't hesitate to ask if not :)
    – fischi
    Commented Feb 20, 2013 at 8:26
  • Ah ok cool, now I understand it. Thank you very much!
    – Sven
    Commented Feb 21, 2013 at 16:11

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.