Ok. I’ve found the solution and will log it here for any other hapless souls who wander down this path.
First, I narrowed the problem down to the following:
Here’s the deal. When I go into the html view of my wp and type in the following code:
<a name="1">Text</a>
And then click normal view and click back to html view, the code changes automatically to:
<a name="1"></a>Text
It does not do this for other people, but it consistently does it for me. Here is some additional info:
It started with wp 3.2
It happens across different computers with different ip addresses
It happens in IE, Firefox, and Chrome
It happens when I log in under different users
Why does this happen and how can I get it to stop happening?
Second, I went to “wp questions” and got the following two responses which solved the issue and explained it:
I can confirm that this problem exists. I am using WordPress 3.2.1 with no plugins and the default theme and I am also affected by this issue.
Steps to reproduce:
– Go edit a post
– Switch to the HTML-editor and enter this exact text: <a name="1">test</a>
– Switch back to the Wysiwyg-editor and again to the HTML-editor
– The code is now changed to <a name="1"></a>test
I think this is a issue with how TinyMCE handles these anchors. I have found the following possible simple solution:
Use the id-attribute instead of name: <a id="some_id">test</a>
works and allows you to jump to that point on the page just like does.
This is related to the tinyMC XHTML behaviour; it forces the use of HTML Standard Attributes the “name” attribute is optional for the anchor tag.
This issue was already reported on the wordpress trac and the conclusion is:
From HTML point of view <a name="bob">Inside</a>
is exactly the same as <a name="bob"></a>Inside
. The anchor is a hidden pointer to where the page should scroll when accessed with https://someurl#anchor.
One question; Why you want to use the name attribute? Maybe you should be using the ID attribute.
hope it helps ??