wordpress bloginfo filter name and description

1k views Asked by At

I was trying to edit my wordpress site name and description, I got that I have to add a filter plugin like so: add_filter( 'bloginfo', 'My_function_name', 10, 2 );.

It works, but I can't understand why we have to add the 10, 2 parameters? and which values it belongs to?

Also there wasn't enough information in codex.wordpress.org

Here is my working plugin :

function edit_bloginfo($text,$show ){
    if (isset($_COOKIE['switch_language'])) {
        if($show == 'description'){
            $text = 'New description';
        }
        if($show == 'name'){
            $text = 'New site name';
        }
      return  $text;
    }

}
add_filter( 'bloginfo', 'edit_bloginfo', 10, 2 );
1

There are 1 answers

1
iEmanuele On

In add_filter( 'filter_hook', 'your_function', 10, 2 ); expression, the 10, 2 parameters are:

  1. the first: the priority of your filter function during the execution of all filter functions. it is a number between 1 and ∞ ( use a reasonable one : ) ), many thanks to @brasofilo: look here.
  2. the latest: the number of parameters that will be passed to your function. The number of parameters declared and the number of parameters passed has to be the same.

Take a look to WordPress Codex Plugin API

Hope it helps!