Sorry for my english, I’m not a native speaker.
I’ve been trying to solve this problem for hours with no luck so far.
The question looks like a duplicate of questions asked previously here on Stack Overflow, but none of the solutions found here worked for me.
TinyMCE wraps anything you put in there inside p tags. I need to change the forced_root_block setting of tinymce to prevent this but I have no idea on how to achieve that on WordPress.
I tried putting the code found here in my functions.php, but It did not work. Also, the problem doesn’t revolve around “wpautop”. It’s just a TinyMCE problem: it puts the p tags as a default behaviour because it needs a root block. In my case I don’t need a root block, because the editor’s content is just a plain text whose root block is in my template’s code. The added p tags simply break my layout, putting unnecessary html elements.
I tried using the TinyMCE advaced plugin, which has this option:
Stop removing the <p> and <br /> tags when saving and show them in the Text editor
but when this is not checked has the effect of “stripping” all the p tags, even the ones I intentionally use in the editor.
All I want to achieve is to prevent the editor from adding unwanted p tags and, at the same time, keep the p tags I intentionally use.
Is there a way to edit the forced_root_block setting of TinyMCE on WordPress?
EDIT: After too many hours I was messing up between two different WordPress installations I was working on at the same time. The solution of the linked post worked for me, but I was checking the results on the other site. By putting this:
in my functions.php, TinyMCE stopped putting anything inside p tags. The
Stop removing the <p> and <br /> tags when saving and show them in the Text editor
of TinyMCE Advaced needs to be checked.You could try to set
You can have a look at this wordpress plugin to change this setting.
Here is another possibility: http://wpengineer.com/1963/customize-wordpress-wysiwyg-editor/
Add this filter to
functions.php
: