siga
11/21/2014 - 5:53 PM

Stop Wordpress editor from stripping your HTML when switching between Visual and text editor or while saving. Be sure to test and keep an ey

Stop Wordpress editor from stripping your HTML when switching between Visual and text editor or while saving. Be sure to test and keep an eye on conflicts with plugins! https://ikreativ.com/stop-wordpress-removing-html/

// stop wp removing div tags - goes to Functions

function ikreativ_tinymce_fix( $init ) 
{
    // html elements being stripped
    $init['extended_valid_elements'] = 'div[*],article[*]';

    // don't remove line breaks
    $init['remove_linebreaks'] = false; 

    // convert newline characters to BR
    $init['convert_newlines_to_brs'] = true; 

    // don't remove redundant BR
    $init['remove_redundant_brs'] = false;

    // pass back to wordpress
    return $init;
}
add_filter('tiny_mce_before_init', 'ikreativ_tinymce_fix');