• At the moment creating an anchor tag with an ID, but without an href causes the wordpress editor to move all the text from inside the anchor tag out side of it.
    <a id="test">This is a test</a>
    get’s replaced with:
    <a id="test"></a>This is a test

    You can work around this by adding an href to the anchor like so:
    <a href="#" id="test">This is a test</a>

    Of course this is a small bug and I’m sure not very many people have this use case, but I figured I’d report it incase anyone else was running into this issue. Or if anyone had the knowledge on what was causing it and how to fix it. Thanks!

    Wordpress Version: 5.8 & 5.9
    PHP version: 8.0

    Steps to reproduce:
    1. Create a fresh installation of WordPress.
    2. Create a new page and add an anchor tag with some text and an ID but no href value using the code editor.
    3. Switch to the visual editor and save the page.
    4. Reload the page and notice that your text is no longer inside the anchor tag.

  • The topic ‘Text editor moves text outside of Anchor tags when ID is specified.’ is closed to new replies.