Fixing Wordpress Editor Replacing HTML div with p tags
quirks, Software, Wordpress

Software 
Wordpress 
WordPress has some annoying quirks. One of these is that the built in editor automatically replaces
<div>...</div>
tags with
<p>...</p>
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.
quirks2 Responses to “Fixing Wordpress Editor Replacing HTML div with p tags”
Leave a Reply
You must be logged in to post a comment.
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…