Stop stripping of p and br
-
I have spent many hours now to find a solution but didn’t.
Since years I use the TinyMCEAdvanced-Plugin’s function “Stop removing the <p> and tags when saving and show them in the Text editor”, because I am working both in the visual editor mostly but also regularly I need to work directly in HTML. By default WP’s HTML Editor doesn’t show the <p> and </br>, which for a programmer is awful and makes it useless. You can not copy your source code into e.g. a text widget because it is missing the tags.But now I use a theme called Avada and its pagebuilder is conflicting with the plugin, adding empty textboxes and <p>nbsp</p> into each module. That’s why I was searching for a function.php solution that simply stops WP from removing my precious <p> and tags when switching from visual to html editor. I found that it should be as easy as
remove_filter( 'the_content', 'wpautop' ); remove_filter( 'the_excerpt', 'wpautop' );
into function.php, but it doesn’t work. It still removes the tags.
I also found
function override_mce_options($initArray) { $opts = '*[*]'; $initArray['valid_elements'] = $opts; $initArray['extended_valid_elements'] = $opts; return $initArray; } add_filter('tiny_mce_before_init', 'override_mce_options');
and
apply_filters('the_content', $your_retrieved_data);
somewhere else, but none of them changes the behaviour.
I am really lost now, and don’t understand why it should be so difficult to get a simple HTML Editor to work as it is suppossed to. I love WP but in some simple basic aspects it frustrates me.
Can anyone tell me a non-plugin solution, that is simply stopping WP to remove <p> and when switching from visual to html editor, so they stay in my code and I can always see them in my HTML?
Thanks a lot
Sofian
- The topic ‘Stop stripping of p and br’ is closed to new replies.