I have a menu made from WordPress that serves as my site’s navigation. Every main item in this menu is a Page Type (redirects to other existing pages) with one of them having submenus that are custom links.
These custom links’ URLs are div IDs from the its parent page. This is how it’s structured.
About Us
- Who we are
- What we do
- How we do
So the submenus URLs are #who-we-are
, #what-we-do
, and #how-we-do
which are sections from the About Us page. Now my problem is that when I am in the About Us page, the submenus links works properly. It scrolls up/down to the section it should. But when I am in another page (let’s say Homepage), it doesn’t redirect to it as it can’t find any section in the page with that div.
Any ideas on what I should put on the URLs instead? Thanks in advance.
To get it to work, you have to attach the id tags to the url (otherwise it is treated as a relative link).
Example:
Suppose your about us page url is “www.yoursite.com/about-us”.
Then to jump directly into a section of this page from external page you need to put anchor tag like this
so you should give url “http://www.yoursite.com/about-us#who-we-are” for your custom link not only “#who-we-are”.
click link and see address bar
WordPress submenu link to a section of page
For this you have to attach the ids with the links of pages from which you want to get redirect to particular section.
Example: Let say your home page be http://www.yourdomain.com/
Now pass the id with this as : http://www.yourdomain.com/about-us/#who-we-are
These should be the ids of the div’s on about-us page.