Posts RSS Comments RSS 15 Posts and 4 Comments till now

Fixing Wordpress Editor Replacing HTML div with p tags

, ,

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.

2 Responses to “Fixing Wordpress Editor Replacing HTML div with p tags”

  1. on 20 Sep 2007 at 7:14 pmRowland

    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.

  2. on 23 Oct 2007 at 4:39 pmbLuefRogX

    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…

Trackback this post | Feed on Comments to this post

Leave a Reply

You must be logged in to post a comment.

Close
E-mail It