How to prevent wordpress from messing up with your rich editing tags
August 30, 2008 by admin
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.


To help other users:
I searched for a while how to prevent the WP editor from changing my code, how to desactivate wpautop or wptexturize, how to remove the filters, etc, until I came to this post and finally “broke the code” for me. Read on.
So I found and tried WP-allow-tags because I just could not put in a simple script to verify a form in a post. But the plugin did not work for me, so I tried to modify it and create a new wpautop function.
WP then just disabled the plugin as I created a fatal error, but at the same time it gave me the line of code where there was a conflict (I could have found it by searching through the installation of course).
So I went to the wp-includes/formatting.php file and simply commented both function wpautop and wptexturize just leaving the proper return at the end. See below.
function wpautop($pee, $br = 1) {
/*
… lines of code …
*/
return $pee;
}
Same for wptexturize:
function wptexturize($text) {
/*
… lines of code …
return $output;
*/
return $text;
}
That for sure worked for me! No more changing of my HTML or other code in posts when saving. And I did not notice any negative effects so far.
I hope it does work for you too if you need it that way.
Best,
John
[...] posts, like video embed code for sites outside of YouTube or widgets or straight up Javascript. So I found this plugin. But does it work? Let’s find [...]
[...] Raw HTML, which lets you escape your code pretty easily and effectively. This means that, unlike the WP-allow tags plugin (which actually served me pretty well), this one can be evoked on a case-by-case basis and [...]
none of these worked for me. The plugin didn’t work, the formatting div & span tags didn’t work, and commenting out the functions in the formatting.php file broke the display of the whole website. Still, nothing is solving my line break problem
Same as Matt, unable to solve the line break problem. Anyone find a solution for this?
Hallelujah! I was tearing my remaining hair out then I finally realised that wp was messing with my html. I would never have known what to do as I am php-ignorant.
Thank you so much for this. It seems to work fine for me.
cheers
William