How to Add In Page Anchor Links In WordPress Posts

Anchor links can be used to create a link within the same HTML document or page. Anchor links are used in pages with lots of content so that the visitor can quickly jump to a section by clicking an anchor link.

Create Anchor links Within a Post in WordPress

Say you have written a very long post and want to place in page anchor links to some texts in your posts in WordPress. Here is a step by step guide to achieve the same:

1. Open the post for editing and select the text you would want the user to click.

2. Click the hyperlink button and remove the http:// . Now, insert a unique anchor to this link. For example: #anchorname or #firefox etc.

Insert Anchor links in WordPress posts

3. Switch to the HTML tab of the post and find the paragraph where you would want the page to scroll down once the user clicks the link that you created in step 2.

4. Include <div id=”anchorname> before the begining of the paragraph and include </div> at the end of the paragraph.

Anchor links in WordPress posts

5. Save the post and preview it. Click the link and the page would automatically scroll to the paragraph where you have included the corresponding <div> tag.

Create Anchor links Across posts in WordPress

You can create similar anchor links to and from other posts of your blog. Suppose you want to create an anchor link from post 1 to a paragraph at post 2. First, open post2 for editing and include the unique div tag (e.g <div id=”somename”> paragraph </div>.

Next, open post 1 and select the text with which you would want to create the link. Click the hyperlink button and enter the full URL of post 2 followed by the id of the anchor link. ( i.e http://yourblog.com/post2#somename).

Email this article

Written by on Monday, February 15th, 2010

  1. Reader Comments

  2. bimbolera

    this part:

    http://yourblog.com/post2#somename

    isn’t working huhu!

    February 25th, 2010
  3. Amit Banerjee

    @bimbolera: That’s just an example to illustrate how anchor links work in WordPress. Have you tried the procedure as described? It works perfect, I bet. Thanks for your comment

    February 28th, 2010
  4. Debajyoti Das

    Another way is to use Anchor Heading

    And link as page.com/page#anchorname

    by using text

    May 22nd, 2010
    • Amit Banerjee

      @Debajyoti: Yes , that procedure works too but just in case you want to link to anchor tags across multiple pages, you have to include a unique div id. Thanks for the comment.

      May 22nd, 2010
  5. Doug C.

    Amit, thanks for this post. This was the only thing that worked for me after an hour or so of searching around.

    July 28th, 2010
    • Amit Banerjee

      @Doug: I am glad it worked, thanks for the comment.

      July 28th, 2010
  6. Diane Vautier

    Thanks so much for this post. I’m not a programmer and this was helpful to have someone hold my hand through it. I used it today!

    I changed it up slightly. I had a post that appeared on the blog homepage and contained a “Read More” link. I had text above that, which I wanted to link to the expanded page. I had to add the full url address before the #anchorname code. No space after the end of the url and the #anchorname.

    It worked like a charm. Thanks again. Great post for us marketers without any coding background.

    Diane
    @dvautier

    August 10th, 2010
  7. Christopher

    Thanks Amit for this useful advice.

    Christopher

    August 19th, 2010
    • Amit Banerjee

      @Christopher: I am glad you found it useful. Thanks for the comment.

      August 20th, 2010
  8. Cuadie

    Am writing an article now and was wondering if it was possible. I guess it is, going to try it right away:).

    November 13th, 2010
  9. rosemary neave

    thanks, sorted it and twittered how cool it was

    November 14th, 2010
  10. Andy

    Thanks, this was exactly what I was looking for. I tried a couple of other methods but they didnt work.

    December 8th, 2010
  11. Nagi

    Thanks, I tried-it and it works! Great
    Here is the link I tried :
    http://escrimeliban.com/championnat-mediterranneen/reglement/#englishtext

    January 7th, 2011
  12. Lorene

    I’m trying to link text from 1 page to another in wordpress and used your suggestion above and it doesn’t work.

    Is there a different way to link text from page to page in wordpress?

    March 17th, 2011
    • Amit Banerjee

      @Lorene: You might want to double check the source code of the post again and check for errors of the “”. WordPress handles double quotes very badly. The above method works in any HTML webpage, not just WordPress

      March 22nd, 2011
  13. Lesh

    Thanks so much for this – it works! I’m not a programmer, or that tech savvy for that matter, but these instructions were simple and easy to follow. I have a wordpress.com (not .org) blog, so I thought I would not be able to anchor, but thanks to your instructions, I can!

    April 13th, 2011
    • Amit Banerjee

      @lesh: Glad you found it useful. WordPress Anchor links helps a lot when you have a long post and you want to create easier navigation

      April 14th, 2011
  14. Roxette Mabellon

    div id=”somename” vs div id=”somename”

    First of all thank you for you post. I simply copied and paste the line in my article, just to test it. But it didn’t work. Then I found the quotes you use in the post are different once then wordpress accept. So if somebody is lazy as me and just copy past the line, it will not work, instead past this

    paragraph

    April 15th, 2011
  15. Erik de Vries

    The official html way to link to a position in a page is a bit different.

    Click here to go to anchor1
    Click here to go to anchor2

    Some paragraph....


    This is the paragraph where the anchor1 link scrolls to


    This is the paragraph where the anchor2 link scrolls to

    May 5th, 2011
  16. Erik de Vries

    I’m sorry, the comments don’t allow me to show the html

    I’ll try something else..

    Click here to go to anchor 1

    May 5th, 2011
  17. Erik de Vries

    Again no luck. Code and pre tags don’t work here. So I cannot demonstrate what I mean.

    <a href=”#anchor1″>Link to anchor1</a>

    May 5th, 2011
    • webmaster

      @Erik: I understand what you’re trying to convey, but for security reasons, HTML codes are disabled in the comment form.

      May 5th, 2011
  18. Erik de Vries

    Ok this works, unfortunately I cannot delete my previous comments. So one more time.

    The official html way to link to a position in a page is a bit different.

    <a href=”#anchor1″>Link to anchor1</a>

    <p>Some paragraph…</p>

    <a name=”anchor1″></a>
    <p>This is the paragraph where the link will scroll to</p>

    May 5th, 2011
  19. Erik de Vries

    @webmaster I understand your reasons. However, in an article that’s about coding, it’s a bit strange you cannot share code examples in comments. Well, finally I managed hehe.

    cheers,
    Erik

    May 5th, 2011
  20. Andrew

    Hi – Can you help. All of a sudden my site URL gets a # at the end when you type in the normal URL. This is along the lines as this discussion but can’t really understand what is going on. I’m not a programmer. Would really appreciate any direction. Thank you
    Andrew

    August 17th, 2011
    • webmaster

      Hi Andrew, can you be a little more specific regarding your problem. What errors are you getting after implementing the steps mentioned in this tutorial?

      August 17th, 2011
  21. Andrew

    Hi – Thanks for your help. i think i have just sorted the problem. It was related to a widget with some java script in it for a webform!! Our hosting service pointed me in your direction because they thought it was to do with ‘anchors’
    Thank you for replying,

    August 17th, 2011
  22. Caryn

    :>)
    Awesome! thx!
    worked perfect.

    November 2nd, 2011
  23. Giorgos

    Great article…I have used plugins that didn’t work and with your help everything is solved…congruts….:D

    December 6th, 2011

Add Your Comment

All Comments are Moderated.

YOUR COMMENT

About This Site

Ampercent is a technology blog on computer tutorials, software guides, how to tricks and web tools. The blog is updated daily and written by two computer science students from India. Read More »

Tip Us »

Have a great tip which you want to share with fellow readers? Send in your ideas to tips@ampercent.com