I am using ACF, and using TinyMCE Advanced plugin.
When editing posts, the editor inserts new links into p tags, which I am trying to prevent as I am using the code tag and if there is a return within the code within the code tag, it wraps it in a new p and code block that then breaks the layout of the post.
I have tried playing with the plugin settings to check to remove the p tags, however no luck.
I have searched and found that I should be setting forced root block to false, however I am still unable to get it to work:
add_filter('tiny_mce_before_init', function ($init) {
//Prevent <p> tags in editor
$init['forced_root_block'] = false;
$init['force_br_newlines'] = false;
$init['force_p_newlines'] = false;
$init['convert_newlines_to_brs'] = false;
return $init;
});
When viewing the post in Text tab, the code shows no P tags, however when editing within the visual tab, its breaking it all out into p tags.
Any ideas on how to resolve?