Wordpress keeps "cleaning" my html post format

So here I find myself again struggling with the wordpress wysiwyg editor. my client asked to translate his website to WG. No problem, light breeze :). It was really easy, migrated from one DB structure to another, and everything went fine.

Now I have a problem. The old site used an editor that added the <br

> and tags <p>

to the content to format it (sounds legal to me). But wordpress won't allow these tags. whenever a client tries to edit a post, WP removes any HTML tags it considers "illegal".

So, I went looking. I first tried installing some of the recommended plugins I found for this problem (like this one ). Didn't work at all for me (for some others I believed it) ...

Then I found a post that told me to add a function to the function.php file that will remove the filters:

function mod_mce($initArray) {
$initArray['verify_html'] = false;
return $initArray;
}
add_filter('tiny_mce_before_init', 'mod_mce');

      

and also this:

function my_tinymce( $init ) {
$ext = 'div[id|name|class|style]';

if ( isset( $init['extended_valid_elements'] ) ) {
    $init['extended_valid_elements'] .= ',' . $ext;
} else {
    $init['extended_valid_elements'] = $ext;
}
 return $init;
} 
add_filter( 'tiny_mce_before_init', 'my_tinymce' );

      

functions from this thread . No, it didn't work either ...

Anyone - any idea? It seems so silly, but there is so much controversy around this topic ... Thanks

+3


source to share


1 answer


You can try this to remove the filters wpautop uses to filter content and excerpts, just put them in funcions.php file

remove_filter( 'the_content', 'wpautop' );
remove_filter( 'the_excerpt', 'wpautop' );

      

Link: Wordpess wpautop

To make older content with p and br loaded into tinyMCE



function my_tinymce_config( $init ) {
    $init['remove_linebreaks'] = false; 
    $init['convert_newlines_to_brs'] = true; 
    $init['remove_redundant_brs'] = false; 
    return $init;
}
add_filter('tiny_mce_before_init', 'my_tinymce_config');

      

Ref: setting up tinyMCE look at Cleanup / Output and try playing with them.

Another way might be helpful Link

tinyMCE.init({
    ...
    verify_html : false
});

      

+3


source







All Articles