Recently one of our readers asked us how to anchor link from one WordPress page to another page with a specific location? An example could be link to an image on another page or post so when clicked, directly jump to that image.
In HTML, such links are known as bookmarks. Let’s see how to create bookmarking links in WordPress.
To create a bookmark link in WordPress between two different pages or posts, we need to create a link pointing to the target element with an assigned id attribute.
For example, if you are writing a post and want to create an anchor link pointing to a sub-heading somewhere in the middle of another post, the workflow will be:
<a href=”otherpostURL#anchor-name“>Link to heading in Post B</a>
In WordPress, to add an id attribute as above, you have to switch to Text editor from Visual editor.
While creating bookmarking link in your post, make sure to add #id at the end of the post URL link. See an example below.
When the anchor link will be clicked, it will take visitors to the linked post but automatically scroll to the location where you have added that id.
- Creating page jump menus for long articles
- 5 PHP mistakes to avoid in WordPress
- How to find and edit CSS in WordPress
In order to create a link from one page to an element of another page in WordPress, you have to create an id for that element and then link to that id.