To add an action for a filter, you should use:

add( 'filters', 'filter name', 'callback' );

 

such as in the following example:

function test_filter( $content ) {
$new_content = ucwords( $content );
$new_content .= ' ... and now with a filter applied';
return $new_content;
}
add( 'filters', 'content', 'test_filter' );

or the same thing using a class:

class filters {
public static function test_filter( $content ) {
$new_content = ucwords( $content );
$new_content .= ' ... and now with a filter applied';
return $new_content;
}
}
add( 'filters', 'content', array( 'filters', 'test_filter' ) );

 

Before applying filter:

After with the filter applied:

Add custom filters

 

Using do_content() function

do_content( $content = '', $escape = false, $use_emoticons = true, $use_shortcodes = true, $allow_filters = true, $filter = 'content' );
such as in the following example:
do_content( 'Just text ...', false, true, true, true, 'my_custom_filter' );

 

The example is on an existing hook in our default theme, to see all existing hooks in our default theme please click here