How To Accept Multiple Parameters in WordPress Filters
April 15th, 2006 by Angsuman ChakrabortyThis is for WordPress Plugin and Theme developers. Don’t read further if you are not one of them.
To get an extra argument in your filter (say for a ‘bloginfo’ filter) you have to specify not 2 but actually 4 as number of arguments in add_filter (read below for details). The returned data are: first argument, filter name, first argument, second argument
BTW: One place where this function is needed is for writing ‘bloginfo’ filter. It passes two arguments - value and key.
So when I add_filter I have to write:
add_filter(’bloginfo’, ‘my_filter’,10, 4 );
10 is the priority
4 is the argument count
And then I access the second argument as:
function remove_css($first_argument,$dummy,$dummy,$second_argument)
I haven’t tried for more than 2 arguments but I suspect it will be equally funky. I have reopened ticket 901 and update the comments.
Tags: CMS Software, Pro Blogging, Web, WordPress | | RSS 2.0 | Trackback this Article | Email this Article










































Add to Technorati Favorites
April 21st, 2006 at 3:47 am
salam