[Resolved] Stop WP visual editor stripping code – solution

Home Forums Support Stop WP visual editor stripping code – solution

  • This topic has 5 replies, 2 voices, and was last updated 5 years ago by Tom.
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #171367
    Tony

    I’m not sure if it works for all code but I have found that using

    around the code stops the WP visual editor stripping code e.g.
    to force a ‘line break’ <div style="padding: 10px;"></div>

    Tony

    #171453
    Tom
    Lead Developer
    Lead Developer

    If I’m going to add an empty HTML tag in the editor I just add an HTML comment inside of it:

    <div style="padding:10px;"><!-- HTML comment --></div>

    That will also stop WP from stripping it 🙂

    #171464
    Tony

    I’m not sure what you mean. I wanted to force a line break and if you use <br> it is stripped out even inside

    the same applies to <p>
    I am finding getting spacing between lines a pain in the rear so landed on using the <div style="padding: 10px;"></div>.

    When you use return or space/return to insert line spaces you can never tell how they’ll be used or what WP will put into the page it seems to me.

    Seems some code is OK and some not but there’s no list of what works and what doesn’t.

    Using the two image idea to have a small image in the excerpt I had to make a gallery the ‘full-image’ and again wrapped it in a

    .

    I’d use the text editor all the time but a) I’m not much on htmal because I always used WYSIWYG Dereamweaver so I just experiment to see what works b) the visual editor makes inserting media so easy.

    Wild West!

    #171601
    Tom
    Lead Developer
    Lead Developer

    The editor shouldn’t actually strip <br /> tags at all – they’re pretty important.

    While using the “Visual” tab, hold Shift + Enter to create a one line break (not a paragraph).

    <p> tags and <br /> tags won’t show in the “Text” tab, but if there’s an empty line between paragraphs WP will create the paragraph, and if there’s one line break between lines it will create the <br /> tag.

    #171623
    Tony

    The editor shouldn’t actually strip <br /> tags at all – they’re pretty important.
    Yes, but it does.
    I don’t find the WP editors are consistant.
    I agree with what you say and understand the shift+enter etc. but, as an example, I wanted a gap between an inserted image and the first line of text under it.
    No matter what combination of enter I used it would change when I opened the page in visual editor.
    I think the way it is interpreted is dependant on unknown parameters but using the
    <div style="padding: 10px;"></div> works every time.

    So far as I can tell the editor has been complained about for years – it’s more like a mark-down editor than mark-up but doesn’t behave like one.

    #171700
    Tom
    Lead Developer
    Lead Developer

    It’s definitely not perfect – always being improved though.

    If you have an example of an image needing space below it I may be able to help.

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.