[wp-hackers] Basic filter question

Austin Matzko if.website at gmail.com
Mon Sep 15 19:24:12 GMT 2008


On Mon, Sep 15, 2008 at 1:44 PM, scribu <scribu at gmail.com> wrote:
> Hello, I was wondering if it was possible to pass an extra argument to a
> function called from a filter, e.g.
>
>
> function my_function($content, $extra_argument) {
>    // Do something to the $content based on $extra_argument
> }
>
> add_filter('the_content', 'my_function', 10, 2, 'extra_argument_value1');
> add_filter('the_excerpt', 'my_function', 10, 2, 'extra_argument_value2');

That won't work, but you could do
add_filter('the_content', create_function('$content', 'return
my_function($content, "extra_argument_value1");'),  10);

However, there might be some performance issues with that.


More information about the wp-hackers mailing list