Why is WordPress WYSIWYMG and how do I make it WYSIWYG?

WordPress may have a text editor that appears to be WYSIWYG, but upon using it I discovered that it is actually WYSIWYMG- What You See Is What You Might Get (once it’s done screwing with the HTML).

Isn’t there a way to tell it to do nothing with the text you put into it? Just leave it as it is. No optimizations, no trying to guess what I meant, no correcting my HTML, no converting whitespace into nbsp’s that for some reason cause line breaks, no changing the formatting or the spacing between embedded objects after you edit it to fix one typo…

I did try searching the settings area but found only one HTML related option (regarding matching closing tags).

2 Answers
2

After you post your content, WordPress will pass the_content() function through a number of filtering function’s. There are four of them, wptexturize(), convert_smilies(), convert_chars(), and wpautop(). All of these are defined in wp-includes/formatting.php and are referenced in wp-includes/default-filters.php.

To remove these filtering functions you can disable them by putting this in your functions.php theme file:

remove_filter('the_content', 'wpautop');
remove_filter('the_content', 'wptexturize');
remove_filter('the_content', 'convert_smilies');
remove_filter('the_content', 'convert_chars');

That should remove all formatting between what you save in TinyMCE (the WYSIWYG editor) and the front end view of your website. For more reference on what each of these does refer to the codex.

I hope this helps, best of luck!

Leave a Comment