Fixing WordPress Editor Replacing HTML div with p tags
by Rowland on Thursday, September 20th, 2007 | 3 Comments
WordPress has some annoying quirks. One of these is that the built in editor automatically replaces
<p></p> tags with <div></div>
Very annoying!
The solution is to find the file wp-includes/js/tinymce/tiny_mce_config.php.
Find the line
$valid_elements ='p/-div[*],-strong/-b[*],-em/-i[*],-font[*],-ul[*],-ol[*],-li[*],*[*]';
Change it to
$valid_elements ='-strong/-b[*],-em/-i[*],-font[*],-ul[*],-ol[*],-li[*],*[*]';
This fixes the annoyance.
No related posts.






After investigation, it seems that whilst this does the trick ,it also breaks the built in functionality of the TinyMCE WYSIWIG editor.
Another solution is to use the TinyMCE advanced plug in (Google it). It comes with a native HTML editor where you can happily use DIVs.
Fixing WordPress Editor Replacing HTML div with p tags…
I’ve just installed WordPress again after a long absence from the blogosphere and I’ve found that WP likes to replace
<div>…</div>
tags with
<p>…</p>
This is kind of annoying for me as some of my pos…
I have provided a simple workaround for this issue wherein I found your comment on the post.
http://www.nietoperzka.com/wptraining/editing-captions-forum-inspiration/