How to Link to Page Content from a WordPress Navigation Menu
Sometimes you might want your WordPress navigation menu items to link directly to a page section that sits in the middle of a larger page, rather than simply to the top of the page. For example: instead of creating a nav menu link to a Contact page, how do I create a menu link to the Contact section of my homepage?
Being able to create WordPress menu links to page sections is especially important on one-page websites, or on multi-page sites that have long scrolling homepages or sales pages. Either of these types of website might have, for example, “How it Works,” “Demo,” “Testimonials,” and “Buy Now” sections all on the same page.
To link to a page section, you’ll need to create a WordPress menu link to an anchor: a link embedded in your page content. Anchors are one of the web’s oldest technologies, and they still work great.
Fortunately, assigning an anchor to a page section, and then linking to that anchor from your WordPress navigation menu, is not tricky at all. This quick tutorial video shows you how.
And here’s a quick text summary of the information covered in the video:
How to Make WordPress Nav Menu Links to Page Sections
- Give the item you want to link to an
<h2 id="target-element">Section Title</h2>. This
idattribute is the element’s anchor.
- In the Menu area in either
wp-adminor the Customizer, create a new Custom Link to add to your navigation menu.
- Set the Custom Link to point to the page on which the content lives, plus the
#character, plus the value of the element’s
- Save your changes to the menu, and test the link from a few pages to make sure it works.
And that’s it! Creating WordPress menu links to page sections using anchors can be a very helpful way to orient your site’s visitors, so give it a try.