Created
November 21, 2014 17:53
-
-
Save SiGaCode/8d5395bfd65c4b2b7395 to your computer and use it in GitHub Desktop.
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/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In my test this actually removes the entire visual editing toolbar.