• 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

Viewing 2 replies - 1 through 2 (of 2 total)
  • Matt Knowles

    (@aestheticdesign)

    The Avada theme may be doing something that is preventing the changes you made to the functions file from working. That theme is a commercial theme and volunteers here don’t have access to it. You would be better served by using the support services of the developer as they will understand how their theme works.

    You will find support for the Avada theme here:

    https://theme-fusion.com/support/documentation/avada-documentation/

    Thread Starter Sofian777

    (@sofian777)

    Thank you Matt, maybe I should not have mentioned the theme, because the code I presented doesn’t work in any installation, also with the simple twenty twelve all these lines didn’t do what I thought they should do.

    But other themes don’t mess with TinyMCE which was my solution so far.

    This is why I search for a solution to solve otherwise. A solution that stops removing p and br, so they don’t get lost when switching from visual to html editor, and is also not adding anything, which most probably is the reason for the theme to add things as well.

    Just the pieces of code as the above mentioned, but they didnt work for me, in no theme.

    I mean what are these lines doing in your installation? Are they working? If you remove the filter autop for example, are p and br preserved when switching from visual back to html? or how can i stop tinymce to remove them, if he is the cause?

    I am lost here, and if anyone has a simple solution, I would be glad, and it is my hope that as a side-effect also the theme will not mess anymore.

    Thanks to all

    PS: And yes, in parallel i contacted the Avada Team. But independent from this I would like to understand how these editor behaviours work and would prefer to solve it few lines of code in my functions.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Stop stripping of p and br’ is closed to new replies.