In this “how-to” series I’m going to show you have to create named anchor links or some people call them anchor tags in WordPress. If you have different sections in a long post or page and you want the visitor to be able to click on a link, say in a table of contents you create, to jump to a different section of that post then you’ll want to use an anchor link. To create anchor links in WordPress is not as straight forward as it should be but just follow the steps below and you’ll easily be able to create anchor links with no coding skills.
To Create an Anchor Link
- Select and edit the page or post you want to create anchor links within.
- Next click the “Text” tab on the post/page to view it source code.
- Now that you can see the pages’ source code you now just need to add this code to wherever you want to place an anchor. Not you can change the id and title in the tag to suit your needs.
<a id="section1">Section 1</a>
- You can now switch back to the Visual tab to create the link. To create the link highlight the text you want the user to click on to just to your anchor link and for the link use whatever the id is in your anchor tag preceded by a the hash symbol. So in my case the link would be:
- And that’s it! Save and Publish or Preview your Draft to test. In my example when I click “How to Resize an Image in WordPress” it will take me to that section. Click the previous link to see a live example.
You can also create named anchor links across pages. So as you can see in the example above instead of jumping to a different section on this post we navigated to a new url and then jumped to that section. To do that just when creating the link enter the url to the page you want to navigate to follow by the hash id. The link above has this code as the link: