WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Stripping simple HTML from posts makes me melancholy (7 posts)

  1. alanfluff
    Member
    Posted 7 years ago #

    I want WP2.1 to stop breaking simple <div id="myDiv"> tags and the like, that I hand-enter as I type in Posts.

    I have dragged through previous support on this and cannot find a simple answer to my simple question.

    I want to write posts with a few, 'simple' HTML tags of my own dropped in.

    Example: I have 6 paragraphs of text, I want three columns on the main body of the page page, each with two paragraphs. Answer: I simply wrap, in code view editor, the pairs of para's in div's that have unique IDs and target them from style.css. This works a treat. Smiles all round. The problem comes if I make any edits (in rich-text OR code editor). When I do this:

    <div id="col1">Hello Dolly, it's nice here...</div>

    ...becomes this...

    <p id="col1"> </p>Hello Dolly, it's nice here...</div>

    I have tried asking WP not to correct XHTML and researched plugins. However, I was hoping to avoid plugins if I could, just looking for the cleanest/simplest setup.

    I am using WP 2.1. I will use a recommended plugin if it's designed to play nicely with 2.1.

    I might perhaps make page templates(?) but I am not sure this will be flexible enough for me and it also sounds like a pretty brutal solution to surely a fairly big question - can I add valid, simple, additional tags to my Posts and know they will be respected? If I could add or could add some (a listed sub-set) it would empower those of us who want to use WP more for publishing.

    Grateful for any response. Thanks in advance,

    -Alan

  2. alanfluff
    Member
    Posted 7 years ago #

    Minor correction; the closing </div> tag is lost all together.

  3. Monika
    Member
    Posted 7 years ago #

    Alan, don't use the what you see is what you get editor and your html tags are always correct.

    regards
    Monika

  4. moshu
    Member
    Posted 7 years ago #

    I make any edits (in rich-text OR code editor).

    I am trying to reproduce the error described by you in the code editor (since I never use the wysiwyg/RTE animal)... and I just can't.

    I've copied your example from here:
    <div id="col1">Hello Dolly, it's nice here...</div> into the text input area and after hitting Enter twice I added this text: "and stuff here in the next p".

    Here is the source code of the result:

    <div id="col1"><p>Hello Dolly, it’s nice here…</p></div>
    <p>and stuff here in the next p</p>

    Notice, the only thing that has been modified by WP is adding the <p>-</p> tags around the text inside the div, which is OK, WP always did that.

  5. alanfluff
    Member
    Posted 7 years ago #

    Thanks for this help. To be as precise as possible, this is what I have done, just re-done to test.

    1. Enter text via the text editor (not WYSIWYG)
    2. Save and view and all nice
    3. Go back into the editor and do nothing except hit save (no changes in the plain text pane and not touching the WYSIWYG whatsoever.
    4. Return to view the site and it's broken.
    5. Go back to the editor and find my code broken.

    Below is the code before and after. I have kept the demo text as large as it was for me *just* in case this has any bearing.

    Thanks again for your fast response and help, one and all.

    Code from step 1. above (works/looks nice)

    <div id="col1">
    <h2>Hello world</h2>
    Quarta decima et quinta decima eodem modo typi qui. Accumsan et iusto odio dignissim qui blandit praesent luptatum. Veniam quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea? Nunc nobis videntur parum clari fiant sollemnes in. Consequat vel illum dolore, eu feugiat nulla facilisis at vero eros et zzril delenit. Nam liber tempor cum soluta nobis eleifend option congue nihil imperdiet doming.
    </div>
    <div id="col2">
    <h2>Hello world</h2>
    Quarta decima et quinta decima eodem modo typi qui. Accumsan et iusto odio dignissim qui blandit praesent luptatum. Veniam quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea? Nunc nobis videntur parum clari fiant sollemnes in. Consequat vel illum dolore, eu feugiat nulla facilisis at vero eros et zzril delenit. Nam liber tempor cum soluta nobis eleifend option congue nihil imperdiet doming.
    </div>
    <div id="col3">
    <h2>Hello world</h2>
    Quarta decima et quinta decima eodem modo typi qui. Accumsan et iusto odio dignissim qui blandit praesent luptatum. Veniam quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea? Nunc nobis videntur parum clari fiant sollemnes in. Consequat vel illum dolore, eu feugiat nulla facilisis at vero eros et zzril delenit. Nam liber tempor cum soluta nobis eleifend option congue nihil imperdiet doming.
    </div>

    Code from step 5. above (broken)

    <p id="col1"> </p>

    <h2>Hello world</h2>
    Quarta decima et quinta decima eodem modo typi qui. Accumsan et iusto odio dignissim qui blandit praesent luptatum. Veniam quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea? Nunc nobis videntur parum clari fiant sollemnes in. Consequat vel illum dolore, eu feugiat nulla facilisis at vero eros et zzril delenit. Nam liber tempor cum soluta nobis eleifend option congue nihil imperdiet doming.
    <p id="col2"> </p>

    <h2>Hello world</h2>
    Quarta decima et quinta decima eodem modo typi qui. Accumsan et iusto odio dignissim qui blandit praesent luptatum. Veniam quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea? Nunc nobis videntur parum clari fiant sollemnes in. Consequat vel illum dolore, eu feugiat nulla facilisis at vero eros et zzril delenit. Nam liber tempor cum soluta nobis eleifend option congue nihil imperdiet doming.
    <p id="col3"> </p>

    <h2>Hello world</h2>
    Quarta decima et quinta decima eodem modo typi qui. Accumsan et iusto odio dignissim qui blandit praesent luptatum. Veniam quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea? Nunc nobis videntur parum clari fiant sollemnes in. Consequat vel illum dolore, eu feugiat nulla facilisis at vero eros et zzril delenit. Nam liber tempor cum soluta nobis eleifend option congue nihil imperdiet doming.

  6. moshu
    Member
    Posted 7 years ago #

    I almost could repeat your error... I said almost because the wysiwyg gizmo MUST be on (even if not used!) to be able to reproduce the <div> transformed into <p> phenomenon.

    If the wysiwyg is totally disabled, then you cannot reproduce it.

  7. alanfluff
    Member
    Posted 7 years ago #

    Yay!

    Thanks so much moshu. I missed the significance of this option and as you say, when it is turned off, the problem dissapears =)

    I must admit, I could not find where to turn off the WYSIWYG, but this post showed me how to turn off the WYSIWYG editor.

    Brilliant =:-)

    Thanks again,

    -Alan

Topic Closed

This topic has been closed to new replies.

About this Topic