Skip to content

Instantly share code, notes, and snippets.

@jasonkiss
Last active May 12, 2016 09:17
Show Gist options
  • Save jasonkiss/a5a15200c0591f2c7b6508bf63e23be2 to your computer and use it in GitHub Desktop.
Save jasonkiss/a5a15200c0591f2c7b6508bf63e23be2 to your computer and use it in GitHub Desktop.
Remove empty <p> from WordPress content. Prevent TinyMCE in Wordpress from wrapping non-block elements or text nodes in <p> tags or injecting empty paragraphs. Fixes the problem where moving from the textual to the visual editor causes unwanted <p>&nbsp;</p> to be added. See https://www.tinymce.com/docs/configure/content-filtering/#forced_root_b…
<?php
function override_mce_options($in) {
$in['forced_root_block'] = false;
return $in;
}
add_filter('tiny_mce_before_init', 'override_mce_options');
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment