WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] html editor adding </p> before </div> (10 posts)

  1. d00dlz
    Member
    Posted 6 years ago #

    I've been using the WP html editor (I have the "use visual editor" checkbox unchecked in my users options) and it has been inserting unnecessary closing p elements directly before my correct closing div tags. My code won't validate because of this.

    I read a few posts and tried deleting this: p/-div[*], from this line:

    $valid_elements =
    ‘p/-div[*],-strong/-b[*],-em/-i[*],-font[*],-ul[*],-ol[*],-li[*],*[*]’;

    in the wp-includes/js/tinymce/tiny_mce_config.php file.

    It's still adding the unnecessary closing p element.

    Not sure what to do next. Has anyone experienced this?

  2. moshu
    Member
    Posted 6 years ago #

    If you insert your own html tags/code - turn OFF completely the visual/wysiwyg and NEVER turn it on.

    The wysiwyg is for code illiterates who just type text. Decide where do you belong and act accordingly: you cannot have both.

    And if you use the "code" editor - do NOT hit enter twice before your divs. Hitting Enter 2x = paragraph.

  3. d00dlz
    Member
    Posted 6 years ago #

    I did turn it off, though. Unless I missed a step in turning it off. I deselected the visual editor checkbox, like I said before. Is there some other way to turn it off?

    And there are absolutely no spaces around my divs. Should I "clump" the code together so it all runs together as one line? Would that help? It makes it harder for me to read, but I guess if it would work.

  4. moshu
    Member
    Posted 6 years ago #

    Since you were talking about tinymce files... I didn't notice that it was turned off. If it is turned off - leave the tinymce files alone.

    Any plugins turned on that may affect your output?

  5. d00dlz
    Member
    Posted 6 years ago #

    Yes, it works when I put the divs on the same lines as the ps. Sorry I should have realized this earlier.

  6. moshu
    Member
    Posted 6 years ago #

    Furthermore: fix your permalinks on the blog: http://tracystoneart.com/blog/
    and then give a direct link to a post that doesn't keep the formatting.

  7. d00dlz
    Member
    Posted 6 years ago #

    Okay, so far it works when I make sure the closing div comes directly after the closing p. Like this:

    <div>
    <p>blah blah.</p></div>
    <div>
    <p>blah blah.</p></div>

    I'll post a direct link to a post if anything should go wrong again. Thanks for your help.

  8. moshu
    Member
    Posted 6 years ago #

    The html editor interprets
    Enter x 1 = br
    Enter x 2 = p

  9. d00dlz
    Member
    Posted 6 years ago #

    Right, I see now, thanks!

  10. aardvarkweb
    Member
    Posted 5 years ago #

    There's a great plugin which wraps code with a comment to prevent the code from being altered by the html editor. It's at http://w-shadow.com/blog/2007/12/13/raw-html-in-wordpress/ and works in 2.6.2.

Topic Closed

This topic has been closed to new replies.

About this Topic