Why is editor adding extra HTML code on ordered lists

I have a series of tutorials that I've created. I'm using a class for my ordered lists called "steps".
I've noticed that if I switch to the Visual editor tab or edit my post, WordPress adds extra code.

As example, I'll have something like this

<ol class="steps">

  • Step 1
  • Step 2
  • Image of some sort

  • Step 3
  • If I make an edit or switch tabs, I often get code like this:

    <ol class="steps">
    <ol class="steps">

  • Step 1
  • Step 2
  • <ol class="steps">
    <ol class="steps">
    Screenshot image of some sort

  • Step 3
  • I can't find a pattern except that maybe the image is involved.

    • Tyler Postle
      • CGO

      Hey Anne,

      Hope you're doing well today!

      Is this with just the normal WordPress editor or do you have a visual editor plugin as well?

      Do you mind granting support access so I can see it happen first hand? :slight_smile:

      You can grant support access via WPMU DEV > Support > Support Access > Grant Access.

      When you actually post it does it display correctly?

      Look forward to hearing back!

      All the best,

    • Anne
      • WPMU DEV Initiate

      Hi Tyler,

      I'm building the site on my PC using ServerPress so you wouldn't be able to see it. I'm playing around with using <ol class="steps" start="8"> to see if I can get around it.

      To answer your other questions. No, I'm just using the native editor and didn't install any visual editor. I only use the Visual tab to see how things look, but I write on the Text tab.

      No, things didn't look good if I were to publish in the browser because the number sequences would restart. I also don't want the duped lines as I suspect they will cause some validation error down the line.

      I also checked the box on Setting | Writing which reads "WordPress should correct invalidly nested XHTML automatically". It didn't seem to fix the issue.

    • aristath
      • Recruit

      Hello again @Anne, I hope you're well today!

      Can you please try this again but this time without switching to the visual editor at all?
      Just add your HTML in the text editor and then publish it, whithout EVER switching to the visual editor.

      Let me know if that works!


    Thank NAME, for their help.

    Let NAME know exactly why they deserved these points.

    Gift a custom amount of points.