Need help — Trying to set a navigation menu anchor link with query params, but it keeps getting rewritten with the query params stripped out

Hello.

I’ve recently been asked to help a local community organisation with their pre-existing website. The website has been built on WordPress, using the Salient theme with WPBakery. I’ve been given access to the WordPress admin account, but don’t have FTP access or anything like that.

**The problem:**

I fixed various things around the website that were incorrect due to a lack of maintenance, and thought I was done. Then I noticed that a new issue had appeared — something that I hadn’t even touched had broken! And I’m not sure how to fix it. The problem I have now is with some of the navigation links:

* The home page has a tab group, discussing different community projects that the organisation is involved with. The navigation menu is configured to have links to each tab in the group, with the general format of `https://website.com/?tab=tab1#projects`. The `?tab=tab1` query parameter is there to load the home page with the specified tab opened, and the `#projects` anchor is there to scroll down to the tab.

* On any page other than the home page, these links work exactly as expected, as described above.

* On the home page, these links seem to get rewritten to just `#projects`, with the absolute link and the query parameters stripped out. As a result, there are several menu items all with the exact same `#projects` link, and all clicking on them does is scroll down to the tab group, without switching to the correct tab!

**My thoughts about what is happening:**

As far as I can tell, *something somewhere* is checking if the `#projects` ID exists somewhere on the page, and if it does, then it rewrites the link. I’m concluding this based on the fact that the links work fine on the not-home page (where there is no `#projects` tab group), and because if I change the links to something like `https://website.com/?tab=tab1#projectstest` then they show up correctly on the home page (because `#projectstest` doesn’t exist).

I’m not sure what’s rewriting the link. My best guess is that it would be related to the [One Page Scroll Support (Animated Anchor Links)](https://www.youtube.com/watch?v=Rj-NQ3YItlc) setting, which is enabled in Salient’s General Settings area. This makes it so that anchor positions are scrolled to via an animation, instead of the browser jumping straight to them. Presumably this feature must look for the anchor link and position, and wire up some JavaScript to create the animation. And it’s probably rewriting the link as well? I don’t know for sure though, and could be completely wrong.

I definitely hadn’t touched these menu items, and I verified using the Wayback Machine that they worked properly on the home page in the past. I assume the original website developer worked around the issue somehow, or perhaps a WordPress/theme/plugin update changed the way things are working. I did make other, unrelated changes to the menu (adding another menu item) and to the home page (adding some custom CSS), so perhaps doing that cause the page to be re-generated and the menu ended up different due to some underlying software change. But then again, there doesn’t seem to be any caching set up, so this must mean WordPress has always been generating the page dynamically on-the-fly, so I’m not sure why it’s suddenly broken now…

**Possible solutions?**

1. Stop it from rewriting the URL somehow. I just want it to keep the same URL that I typed in, instead of thinking it knows better and changing it. This is my ideal solution, but I’m not sure how to do it. Remember that I don’t have FTP file access. I had a look through some PHP files in the Appearance -> Theme File Editor section of the WordPress admin panel, but couldn’t find anything relevant.

2. Accept that it’s rewriting the URL, and find an alternative means to switch to the correct tab. Perhaps I could add some JavaScript somehow, so when clicking a `#projects` link, the tab group switches to show the correct tab. This approach might be better even, since it wouldn’t involve reloading the home page, but it would fail if JavaScript is disabled. I’m not sure how to go about doing this though.

3. Install a caching plugin and then edit the final generated HTML output for the page to correct the links. This would be a hacky solution, as it would break again whenever someone edits the menu or page to cause a regeneration. I’m also not sure if I even can install plugins or edit the cache files without FTP access.

I’d appreciate any help or advice with this. I was supposed to be fixing it up, not creating new issues. Thanks in advance.

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer