Twitter
LinkedIn
YouTube
RSS
Facebook
ClickBank1

Fixing WordPress Editor Replacing HTML div with p tags

VN:F [1.9.10_1130]
Rate This Post..
Rating: 8.5/10 (6 votes cast)

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.

VN:F [1.9.10_1130]
Rate This Post..
Rating: 8.5/10 (6 votes cast)
Fixing WordPress Editor Replacing HTML div with p tags, 8.5 out of 10 based on 6 ratings

No related posts.


3 Responses to “Fixing WordPress Editor Replacing HTML div with p tags”

  1. Rowland says:

    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.

    VN:F [1.9.10_1130]
    Rating: 0.0/5 (0 votes cast)
  2. bLuefRogX says:

    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…

    VA:F [1.9.10_1130]
    Rating: 0.0/5 (0 votes cast)
  3. mongobread says:

    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/

    VA:F [1.9.10_1130]
    Rating: 0.0/5 (0 votes cast)

Leave a Reply

Spam Protection by WP-SpamFree