Support » Fixing WordPress » Anchor links not working properly

  • Hi,

    I’m having a frustrating problem: My anchor links (fragment links) are not working properly for reasons I don’t understand.

    My privacy policy has lots of sections, so I added anchors to help visitors jump to specific sections. I want to be able to let people go to those specific sections in links from other pages as well. For instance, I have a payment button that refers people to the section of the privacy policy on financial transactions, so I have a link to that anchor right under the button.

    The problem is that this doesn’t work properly in Firefox. The fragment link resolves, but immediately goes to the top of the page. Once the visitor is on the privacy policy page, the fragment link will go to the anchor, but it requires clicking return or reload on the address bar, which is very inconvenient.

    The anchors are identified with both id= and name= (I understand the latter is deprecated in HTML 5), using identical identifiers. I checked to make sure all the anchors are closed immediately rather than wrapped around other elements. I also tried completely removing the name= attribute (just using id=) and just using name=. As an experiment, I also tried applying the id attribute for one anchor directly to the applicable heading tag, removing the separate anchor tag. All these variations behave the same way: They work fine if the visitor is already on the privacy policy page, but don’t work otherwise.

    This does not appear to be an issue in Chromium-based browsers, but is a problem in Firefox.

    Does anyone know how to resolve this problem? Web searching suggests it’s been a Firefox issue for a long time and the only workarounds I’ve seen involve using JavaScript to force a page reload, which does not sound like a great solution on a site that’s already straining the resources of its shared server.


    The page I need help with: [log in to see the link]

Viewing 6 replies - 1 through 6 (of 6 total)
  • I think the script is interfering. We fixed a similar issue with a scroll-to-top script last week in the upcoming Twenty Twenty theme.

    Can you try disabling the plugins that put the scripts on the page? You can use the Health Check plugin to try it out for your user only.
    (I see that Firefox no longer has a built-in way to turn off javascript.)

    Thread Starter Ate Up With Motor


    It does not, but I have NoScript, so I can turn it off for the entire site in Firefox. Scripts being turned off seems to avoid the problem, so I guess the next question is which plugin is responsible or if it’s something in the theme that’s doing it.

    Thanks for the heads up about Health Check — I’ll give that a shot.

    @ate-up-with-motor @joyously

    I’m having the same issue with our company’s privacy policy. The anchor tags when first clicked, takes you to the top of page and then when clicked the second time, takes you to right section. I was messing with it extensively and getting the same results. I turned off the plugins and still same result. Internet search turned up nothing of help. @ate-up-with-motor, were you able to solve your issue?@joyously, you mentioned you solved it with a scroll-to-top script? would you be able to share that specific function? hope it’s not asking for too much. I need to solve this and then i’ll circle back and learn from it. It’s driving me nuts!
    Thank you, Michael

    Thread Starter Ate Up With Motor


    Unfortunately, I have not. It seems to be at least partially theme-specific (I have a site with the Astra theme that is NOT having this problem).

    If I understand her correctly, I believe what Joy was saying was that the issue was caused by a scroll-to-top script (rather than such a script fixing it). That seems to be what’s happening to me — it looks like the anchor link resolves correctly and then some script overrides it and sends it back to the top of the page. Once the user is ON that page, the anchor links function normally, even if they hit refresh/reload or just hit return in the address bar.

    same issue there, I have it for a few weeks at least.

    With me here it is not working. The #something is replaced by % something.. so it is interpreted as of there was a space.

    What to do?

    regards Marja

    • This reply was modified 1 year, 4 months ago by arttrust.
Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Anchor links not working properly’ is closed to new replies.