apply_filters(‘the_content’, $content) alternative

The Core filters on the_content are:

131 add_filter( 'the_content', 'wptexturize'        );
132 add_filter( 'the_content', 'convert_smilies'    );
133 add_filter( 'the_content', 'convert_chars'      );
134 add_filter( 'the_content', 'wpautop'            );
135 add_filter( 'the_content', 'shortcode_unautop'  );
136 add_filter( 'the_content', 'prepend_attachment' );

You can apply whichever of those you’d like to any string you’d like. The second parameter is the name of a function which takes a string as input, so…

$str="this is my content";
$str = wptexturize($str);
$str = convert_smilies($str);
$str = wpautop($str);

And so on. Use the ones you want. Ignore the others. That should give you plenty of control. Plugins cannot hook in if there is no hook, but be careful robbing a theme of expected functionality is unfriendly and could break things.

http://codex.wordpress.org/Function_Reference/wptexturize
http://codex.wordpress.org/Function_Reference/convert_smilies
http://codex.wordpress.org/Function_Reference/wpautop

Leave a Comment