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 *

*

Recommended Videos

Wordpress editor strips p tags [solved]
Wordpress editor strips p tags [solved]
How to Edit Footer Copyright Text In Any WordPress Theme
How to Edit Footer Copyright Text In Any WordPress Theme
TinyMCE Advanced - Stop WordPress Stripping HTML in Editor
TinyMCE Advanced - Stop WordPress Stripping HTML in Editor
How To Customize The Style Of Contact Form 7 To Match Your Website
How To Customize The Style Of Contact Form 7 To Match Your Website
Remove Anything with Inspect Element Custom CSS
Remove Anything with Inspect Element Custom CSS