Trailing newline rendered as a <br /> tag in the last paragraph due to inserted <span>

6. kesäkuuta 2026 klo 13.50
Sijainti: Vianhallintajärjestelmät: Github
Avainsanat: WordPress

The trailing <span class="__iawmlf-post-loop-links"> element introduced in PR #338 causes WordPress to render a trailing newline as a <br /> tag in the last paragraph. This behavior differs from when Link Fixer is not active.

I don’t know if the block editor is affected, since I don’t use it, but the issue is present when using the Classic Editor, and even there you have to use the Code view (because Visual view either converts the trailing newline into a line with an &nbsp;, or strips the trailing newline when switching to Code view).

My guess is that this is wpautop trying to be smart about the content, seeing the trailing <span> from Link Fixer, and thinking it’s visible content, so the trailing newline in the actual content (as entered in the editor) should be rendered as a visible <br /> too.

This is probably a very niche issue, and I’m sure I can figure out a way to work around it, but I wanted to document it anyway.

Steps to reproduce

  1. deactivate Link Fixer
  2. use Classic Editor’s Code view to create a post
  3. end the final paragraph with a newline
  4. preview publish the post and inspect the last paragraph: there is no newline before the closing </p> tag
  5. activate Link Fixer
  6. create another post with the same contents
  7. preview publish the post and inspect the last paragraph

What you expected to happen

the <span> to immediately follow the last word and immediately precede the closing </p> tag, with no newline before or after

What actually happened

the <span> is separated from the last word with a <br /> tag followed by a plain newline

Vastaa viestiin sen kontekstissa (Github)