apply_filters(‘the_content’, $content) alternative

“the_content” filter can get added with other filters from plugins and themes which could alter content, when you simply want this to format the post_content to HTML format.

Is there a better solution for this that other plugins do not add filters to and can format the post content to HTML format just like this filter do?

Related posts

1 comment

  1. 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

Comments are closed.