Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
This snippet will tame TinyMCE within Wordpress and prevent it trying to clean up the code and reformat it. Specifically helps to prevent wordpress strip p tags and line-breaks and stops it from inserting nbsp etc
function mce_mod( $init ) {
$init['forced_root_block'] = 'p';
$init['apply_source_formatting'] = false;
$init['preformatted'] = true;
$init['force_br_newlines'] = true;
$init['wpautop'] = false;
return $init;
}
add_filter('tiny_mce_before_init', 'mce_mod', 99);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.