Forums

Why does WordPress rip out my anchors? (3 posts)

  1. jrprather
    Member
    Posted 1 year ago #

    When I edit a post in HTML and add an anchor to jump down the page, and then I switch back to Visual, and then switch back to HTML again, my anchors have been screwed with by WordPress. Sometimes the entire anchor tag is gone, sometimes WordPress moves them all to the top of the page, and sometimes the anchor remains but the text inside of it is now gone.

    What do I need to do in order to get anchors working? I am making a site professionally and I need to be able to use this functionality (e.g. for a dictionary where at the top is "A", "B", "C", etc, and the user can click those links and it jumps down to the appropriate section). I want to hand over control to the person I'm making it for, but if using the Visual editor screws up anchors then I won't be able to. Help?

  2. stvwlf
    Member
    Posted 1 year ago #

    We prefer to call it "improves" rather than "screws up".

    Seriously, there are certain HTML tags and configurations the WP editor removes. The intent is to keep beginners from getting in trouble but it of course limits things like what you are attempting. And yes at times it is quite a pain.

    I have found code like this
    <a name="whatever"></a><p>description of the named anchor</p>
    works pretty reliably and accomplishes what you are after in a different way. The browser will still jump to the spot on the page that you want it to.

    There are also articles you can google for that describe actions you can add to the theme's functions.php file to modify the tags the editor fools with. I don't have any of them linked or I would post the link.

    You can accomplish what you are after but you will have to find a way the editor will cooperate with - they do exist.

  3. kg69design
    Member
    Posted 9 months ago #

    Yea, it's a big problem with editor in WordPress. I have the same problem as jrprather with anchors. I didn't find a solution yet.

Topic Closed

This topic has been closed to new replies.

About this Topic