Force pure HTML editor in WordPress

After installing WordPress for this blog, I realized that I was forced to use the stupid TinyMCE WYSIWYG editor. I smiled when i found out that I was able to set a HTML editor only flag in my account settings. But this did not turn the editor into a pure HTML editor, since every line i wrote was replaced by <p>{the_line}<p>, which is not practical when you want to paste programming code.

Here is how you disable this unacceptable behavior the easy way (WP kindly asks you to find a plugin that undo the paragraphs, but you know…).

  1. Find the file wp-includes/default-filters.php.
  2. In the section with display filters, uncomment the filters wpautop and shortcode_unautop, that applies to the functions the_content and the_excerpt:
    1. <?
    2. // Display filters
    3. //add_filter( 'the_content', 'wpautop' );
    4. //add_filter( 'the_content', 'shortcode_unautop' );
    5. //add_filter( 'the_excerpt', 'wpautop' );
    6. //add_filter( 'the_excerpt', 'shortcode_unautop');
    7. //add_filter( 'get_the_excerpt', 'wp_trim_excerpt' );
    8. ?>
    Notice the last line that disables the filter wp_trim_excerpt from the function get_the_excerpt. I found this behavior werid too; why trim an excerpt, when an excerpt is already a trimmed article?
  3. If you did not create your own WordPress theme, I use the default myself, be sure to check if other strange content filters are applied. These are probably located in the file wp-content/themes/{theme}/functions.php.
  4. Enjoy creating articles in WP.
This entry was posted in HTML, PHP and tagged , , . Bookmark the permalink.

One Response to Force pure HTML editor in WordPress

  1. Das ist aber wirklich übertrieben dargestellt, oder denkst du nicht?

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>