WordPress.org

Support

Support » How-To and Troubleshooting » Anchor tags in text widget not working

Anchor tags in text widget not working

  • I’m trying to create some basic text bullet points within a text widget using <li> and anchor tags. While the links are going to the correct page on the site, they are not going to the anchors placed on the page. The coding is correct. Is this just not possible to do with the text widget? I did not see anything on the forum specifically about this.

Viewing 15 replies - 1 through 15 (of 16 total)
  • WPyogi

    @wpyogi

    Forum Moderator

    What code are you using?

    Also note that you must put code inside code tags here – otherwise li tags break the formatting of these forums (fixed yours).

    Here’s an example:

    In the text widget:
    <a href="http://mysite.com/faqs#started/"><li>How do I get started?</a></li>

    And on the page I want it to go to:
    <h3><span style="color: #79B7D0;"><a name="started">How do I get started?</a></span></h3>

    WPyogi

    @wpyogi

    Forum Moderator

    name is deprecated – try using id instead.

    It should also go in the h3 tags – you don’t use anchors on that end – so:

    <h3 id="started"><span style="color: #79B7D0;">How do I get started?</span></h3>

    Thanks for the suggestion but it still didn’t work. It just goes to the correct page but is completely ignoring the anchor.

    WPyogi

    @wpyogi

    Forum Moderator

    Where is the page?

    It’s just a regular WordPress page contained on the same site as the text widget. The text widget would be visible on all pages of the site so the bulleted links would always be visible to a site visitor.

    WPyogi

    @wpyogi

    Forum Moderator

    I meant could you post a link to the site so I can look at what’s going on.

    Sorry. Here you go.

    Hair Restoration

    You’ll see the 3 bulleted text links in the right sidebar under FAQ’s. The third one should be anchored to the bottom of the FAQ page at http://hairlosssolutionsnow.com/faqs/#started/.

    There will be more links added but I wanted to make sure it worked before spending more time on this. Thanks.

    Once again here is the code I used on the FAQ page for the anchor:
    <h3 id="started"><span style="color: #79B7D0;">How do I get started?</span></h3>

    WPyogi

    @wpyogi

    Forum Moderator

    Looks like your link has a different URL than where the page really is?

    <a href="http://hairlosssolutionsnow.com/about-hairloss-solutions/faqs#started/">

    vs.

    http://hairlosssolutionsnow.com/faqs/#started/

    WPyogi

    @wpyogi

    Forum Moderator

    IS that a permalink issue?

    That’s interesting. I’m not sure how the “about-hairloss-solutiions” got in the URL but I have removed it from the link and they are still not working.

    Permalinks are set to /%category%/%postname%/

    Could that have something to do with it? I just changed the Permalinks on the site about 2 weeks ago but this FAQ page was just added to the menu today.

    Ok, I ran some more tests on this and put the <li>links on the same page as the anchor tags to see if they would work. The one with the <a name="contracts">worked.

    The one using id in the H1 tag did not. It’s interesting…

    Anyway, nothing seems to work when linking to the anchors from outside the actual page like I wanted to do with the text widget.

    WPyogi

    @wpyogi

    Forum Moderator

    Something is changing the URL when you try to go the linked URL –

    Put this in your browser:

    http://hairlosssolutionsnow.com/faqs#started/

    It gets changed to:

    http://hairlosssolutionsnow.com/faqs/#started/

    Yes, I noticed the same thing. I tried changing the permalinks structure and it did the same thing… I may just end up creating a separate post for each FAQ and link to them from the text widget that way. At least that seems to work. There must be something within the text widget structure or theme that is changing the URL.

    WPyogi

    @wpyogi

    Forum Moderator

    You could try deactivating your plugins to see if any are adding the slash.

Viewing 15 replies - 1 through 15 (of 16 total)
  • The topic ‘Anchor tags in text widget not working’ is closed to new replies.