Fix div tag replacement by p tags in wordpress editor

Div tags are replaced into p tags by the WordPress editor.But now there is a solution to fix this WordPress editor problem.

How to use div tags in wordpress editor?

  • Find the file wp-includes/js/tinymce/tiny_mce_config.php in your wordpress setup.
  • Find the line:

    $valid_elements=‘p/-div[*],-strong/-b[*],-em/-i[*],-font[*],-ul[*],-ol[*],-li[*],*[*]’;
    and Change it to:
    $valid_elements=‘#p[*],-div[*],-strong/-b[*],-em/-i[*],-font[*],-ul[*],-ol[*],
    -li[*],*[*]’
    ;

The above change lets you use <div> tags in wordpress blog posts and they will not be replaced by <p> tags.This would mean that you can embed code in your WordPress editor, without breaking your whole blog’s layout.

Leave a Reply

Your email address will not be published. Required fields are marked *

*