Replies: 1
Hello,
I’m facing a conceptual issue related to WordPress menus. I’ve been asked to look at some malfunctions on a WP site I’ve not designed by a friend (the original designer being unavailable). It’s made this way: the site has a main page which is divided into sections and a few indpendant pages (a blog, a shop…). Its main menu in the header has to link to the several sections of the main page and one or more pages. Basically, it’s setup like this in the admin:
custom link (anchor 1) / custom link (anchor 2) / … / page link
which translates to something like this on the site:
website.com/#anchor1 website.com/#anchor2 […] website.com/shop
All works well as long as you’re on the main page but is broken once the base address is changed by going to another page, as HTML anchors refer to the current page. So when I go to the shop, the menu becomes something like this:
website.com/shop/#anchor1 website.com/shop/#anchor2 […] website.com/shop
The issue being that the custom links (anchors) don’t refer to a specific page, so navigation is broken.
I’m not sure how to handle this in the best way.
I’ve tried to edit the custom links and put a slash before the anchors, so it forces them to check for the root of the site. Technically, it works but
1) it’s a dirty hack as it wouln’t work for a WP setup that’s not installed at root (e.g. website.com/blog or something as the base address)
2) it breaks a script that provides a fancy scrolling effect to the anchor links on the main page
The ideal way to do this properly would be to have an option to add anchors in the page links in the menus setup (in WP admin) rather than relying on custom links but that’s not the case, you can only choose a page with no options. Is there a plugin that does it (i.e. adds an “anchor” field to pages links and rewrites the menu accordingly)? If not, any idea of the best way to fix the issue I’m having?