WordPress editor strips out anchor tags when they appear on their own line

In the text below, when I toggle the WYSIWYG view from Visual to Text, the anchors are left intact. However, when I switch back to Visual, the anchors are replaced with   elements.

This is the initial content markup in the WordPress editor (via Chrome inspector):

<body id="tinymce" class="mceContentBody content post-type-post post-status-publish post-format-standard wp-editor" onload="window.parent.tinyMCE.get('content').onLoad.dispatch();" contenteditable="true" dir="ltr"><p>This is the first sentence break. <a id="bookmark1" class="mceItemAnchor"></a>&nbsp;This is the seond sentence break. <a id="bookmark2" class="mceItemAnchor"></a>&nbsp;This is the third sentence break.</p><p><a id="bookmark3" class="mceItemAnchor"></a>&nbsp;This is the fourth sentence break.</p><p><a id="bookmark4" class="mceItemAnchor"></a>&nbsp;</p><p>This is the fifth sentence break.</p><p><a id="bookmark5" class="mceItemAnchor"></a>&nbsp;</p></body>

And this is what it looks like when I click on “Text” in the WordPress editor iframe:

This is the first sentence break. <a id="bookmark1"></a> This is the second sentence break. 

<a id="bookmark2"></a> This is the third sentence break.

<a id="bookmark3"></a> This is the fourth sentence break.

<a id="bookmark4"></a>

This is the fifth sentence break.

<a id="bookmark5"></a>

What are my options for fixing this so that the anchor tags are not replaced?

0

Leave a Comment