How to prevent wordpress from messing up with your rich editing tags

After spending countless hours fighting with wordpress changing my tags and text formatting in it’s rich text editor I finally decided to create a tiny little cute plugin that makes wordpress to leave alone my HTML formatting, tags and line breaks.

Essentially the source code of the whole thing is this:

function myautop ($text) { return $text; }
function mytext  ($text) { return $text; }
remove_filter ('the_content', 'wpautop');
add_filter    ('the_content', 'myautop');
remove_filter ('the_content', 'wptexturize');
add_filter    ('the_content', 'mytext');

You may download actual plugin from the link below. Just unzip, copy it into ./plugins directory, activate and enjoy.

Note: to fix another big annoyance with WordPress eliminating line breaks – this is what I use to “create” line breaks that WordPress doesn’t kill. In HTML mode insert this code:

<div style="margin:2em;"><span style="display:none;">-</span></div>

Advantage of this method is that you can regulate size of your “custom line break” by changing value in “margin” CSS tag.

Bonus TIP:
Actually I just found a better way to keep linebreaks: Advanced TinyMCE plugin seems to add lot more features to TinyMCE editor as well as has an option to stop WordPress’s messing up with line breaks.

Download: WP-AllowTags
Wordpress Plugin that allows inserting tags