• Hello,

    I am becoming infuriated by the WordPress editor adding unwanted paragraph tags whilst editing pages. I have a few pages where I use divs to organise content, and WordPress adding these paragraph tags in between divs prevents my pages from becoming XHTML valid.

    I am aware of the wpautop function and that there is plugins to disable this, however I do not want to have to do this as it is handy when writing regular blog entries/pages which do not require divs.

    In versions prior to 2.5, removing p/-div[*], from the line $valid_elements =
    ‘p/-div[*],-strong/-b[*],-em/-i[*],-font[*],-ul[*],-ol[*],-li[*],*[*]’;
    in wp-includes/js/tinymce/tiny_mce_config.php fixed this problem. However, in 2.5 and above I can no longer find this line in the aforementioned file.

    Is there a similar solution for versions 2.5 and above, or any hack/plugin that will fix my problem?

    Any help in this matter would be greatly appreciated, thank you.

Viewing 11 replies - 1 through 11 (of 11 total)
  • your problem isn’t so much the wpautop function, it’s that you’re using the visual editor.

    Let me see if I can make this point as strongly as possible, in case there’s any further argument…

    If you’re adding markup to your posts, you should NOT be using the visual editor. Either find a way to add your markup via a custom filter, so you can avoid inserting into your posts, or STOP USING THE VISUAL EDITOR.

    The visual editor is for people who don’t know what markup is.

    I can’t stress that enough.

    Without using the visual editor, you can add div tags to your posts, if you leave a blank line between your previous/following paragraphs and the div. This blank line will not be evident in your final output.

    Though I agree with you regarding the visual editor, it seems to be happening with the old-school editor as well. Just a bunch of unwanted <p> tags wrapping everything. It’s very tedious.

    PJ Brunet

    (@knowingart_com)

    “I can’t stress that enough.”

    I’m not using the visual editor. Here you go straight from Firebug:

    <p>
    <img style=”width: 100px; height: 200px;” src=”https://sitdownsellup.com/pj/red-x.png”/&gt;
    </p>

    Those paragraph tags are not mine. I just deleted the entire tinymce directory off my server to be sure, problem is still there, and no it’s not cached.

    Time for phpmyadmin, ugh.

    PJ Brunet

    (@knowingart_com)

    OK, phpmyadmin was of no help, the paragraph tags are added after the fact.

    What is the function I need to start hacking? Or maybe I can neuter the paragraph tag with CSS, if that’s even possible.

    PJ Brunet

    (@knowingart_com)

    Came up with a temporary hack, added this to my style.css:

    div#post-132.post div.post-entry div p {margin:0 0 -3px 0;}

    If anyone finds a better solution, let me know: [email protected]

    I don’t know why WP would add paragraph tags to posts after they’ve been saved to mysql, but maybe there’s a good reason.

    Straight from phpmyadmin:
    <div style=”width:200px;border:1px gray dotted;”><div style=”float:left;text-align:left;width:80px;padding:10px;”>Write about your picture here.</div><img src=”https://sitdownsellup.com/pj/red-x.png&#8221; style=”width:100px;height:200px;” /></div>

    And straight from “view source” firefox:
    <div style=”width:200px;border:1px gray dotted;”>
    <div style=”float:left;text-align:left;width:80px;padding:10px;”>Write about your picture here.</div>
    <p><img src=”https://sitdownsellup.com/pj/red-x.png&#8221; style=”width:100px;height:200px;” /></div>

    See the “<p>” that got added? Very strange.

    “Without using the visual editor, you can add div tags to your posts, if you leave a blank line between your previous/following paragraphs and the div. This blank line will not be evident in your final output.”

    No, that didn’t work either.

    Hey, no wonder I’m single ??

    I’d really like to get an answer/fix about this problem. Same situation – not using the visual editor .. same result, unwanted paragraph tags everywhere. Anything WordPress?

    Same problem. The <p>’s are very very much unwanted. I want the code that I put in the (non-visual) editor to be untouched.

    Ignore my reply. Hope it won’t break anything, but I commented out

    // add_filter(‘the_content’, ‘wpautop’);

    in default-filters.php

    Luap777

    THANKS!
    that stupid <p> tag at the beginning of every post was driving me nuts!!!

    nintensity

    (@nintensity)

    amazing. good job man!

    Keep in mind it also takes out the <p> tag in front of my blockquote as well as my cite tags. but good work nonetheless.

    There is a plugin that allows per post setting to disable this annoying feature. It’s called WP-Unformatted, the short description says:

    With this enabled, you can add a custom field of ’sponge’ set to ‘1′ to a post to disable the auto formatting and a custom field of ’sandpaper’ set to ‘1′ to a post to disable the auto smart-quote conversion.

    You can get it at: https://alexking.org/projects/wordpress

    It only took some googling to figure out what caused the problem (thanks to this thread for an answer) and only bit more to find this plugin for it ??

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Unwanted <p> tags added to pages’ is closed to new replies.