[wp-testers] apply_filters()

Jennifer Hodgdon yahgrp at poplarware.com
Tue May 26 14:07:17 GMT 2009


Maybe if you posted some of your code, we could see what is going 
wrong? You can definitely apply filters without echoing the result, to 
make something "filterable" in your theme... Example:

a) In your parent theme, do something like this:

$myvariable = apply_filters( 'my_filter_name', $myvariable );

b) In a plugin or subtheme's functions.php, do something like this:

add_filter( 'my_filter_name', 'my_filter_func' );

function my_filter_func( $input ) {
    $input .= ' additional text added to end'; // or other filtering
    return $input;
}

Hope this helps,
    Jennifer

Karl Wångstedt wrote:
> I'm trying to make a function in my parent theme fiterable (is that a 
> correct description?) by apply_filters on the return value.
> 
> But now it seems like I can only add_filter() to the result if it gets 
> echoed from the function. Now I'd like to just return the result for use 
> in PHP, but then the add_filter() isn't applied.

-- 
Jennifer Hodgdon * Poplar ProductivityWare
www.poplarware.com
Drupal, WordPress, and custom Web programming



More information about the wp-testers mailing list