Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

WordPress

Helen Anderson
Helen Anderson
6,519 Points

Internal links within a wordpress post

How do you create internal links within a wordpress post? In other words, how do I replicate the # function from a normal html webpage in Wordpress so I can jump down from a list at the top of the post to sub headings further down the post.

I'm still working my way through Zac's "How to build a wordpress theme", which is great BTW, so if the answer is revealed in this project, please forgive me!

Thanks in advance

4 Answers

John Locke
John Locke
15,479 Points

Hi Helen:

It works the same way. If you want to link to section "foo" on your page, just make a link:

  <a id="foo"></a>

where you want to end up when you click the link. Then put the link in your list at the top:

  <a href="mysite.com/mypage/#foo">Link to Section Foo</a>
Helen Anderson
Helen Anderson
6,519 Points

Oh, how obvious. Thanks John,

I'll try this out.

Zac Gordon
STAFF
Zac Gordon
Treehouse Guest Teacher

John's right :)

Although I would suggest leaving out the absolute link and just doing #anchor instead of domain.com/page/#anchor so that if the page name changes it won't break the link.

I haven't used it, but this plugin might come in handy too: http://wordpress.org/plugins/better-anchor-links/

Helen Anderson
Helen Anderson
6,519 Points

Thanks Zac. I'll try that plug in too.