questions

switching between wordpress text/visual editor makes anchor tags disappear

Rate this post

I am trying to create anchor points in my page for users to jump to. When I create the anchor points in the text editor in wordpress, if I ever switch to visual editor, the anchor tags disappear. Here is the code I am using in the text editor:

<div>
   <a id="posts" class="anchor">&nbsp;</a>
   <h4>Key Blog Posts</h4>
   Andrea Radke-Moss, <a href="http://www.juvenileinstructor.org/mormon-studies-in-the-classroom-mormon-women-patriarchy-and-equality/" target="_blank" rel="noopener noreferrer">"Mormon Studies in the Classroom: Mormon Women, Patriarchy and Equality,"</a> Juvenile Instructor.
</div>

When I switch the the visual editor (regardless if I saved it or not while in text editor), the anchor tag disappears and I am left with this:

<div>
   &nbsp;
   <h4>Key Blog Posts</h4>
   Andrea Radke-Moss, <a href="http://www.juvenileinstructor.org/mormon-studies-in-the-classroom-mormon-women-patriarchy-and-equality/" target="_blank" rel="noopener noreferrer">"Mormon Studies in the Classroom: Mormon Women, Patriarchy and Equality,"</a> Juvenile Instructor.

After doing some research, this seems like a common problem with WordPress when there is no text between the anchor tags (which is why I tried the &nbsp;). Has anyone been able to conquer this problem?

Update: I tried putting a period in between the tags with style="font-size: 0px";. Saved, switched to visual editor, and the period was now outside my anchor tags! Grrrr….

 

✔️Solution:

I finally got something to work. Here’s the code I used:

<a id="posts" class="anchor" href="#posts">&nbsp;</a>

I couldn’t get rid of the &nbsp;, so it still has a clickable spot, but at least when it’s clicked on, it doesn’t jump around like href="#" does.

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button