I am working on my WordPress website and when the user clicks on the <a href="#id"> tag, the #id is not showing in the URL and because of that, when the user clicks on the back button, it is taking me to the back not on the top of the page.

I want that, when the user click on the <a href="#id"> tag and it moves to that id but when the user clicks on the back button, it should take me to the top of the page. Now, it is taking me to the back page.

Any help is much appreciated.

  • You need to give the top its own anchor then, because the url without any fragment it is not automatically associated to the top. Also before any other user interaction, update the url with the fragment you associate to the top, to allow the history go back to it. Nov 29, 2019 at 2:38

1 Answer 1


The solution is: Just add the page scroll id plugin.

After installing the plugin, Go to the Links behavior section:

Check this option: Append the clicked link’s hash value (e.g. #id) to browser’s URL/address bar.

By doing this, id shows in the URL and when you click the back button after going to the id, the page will come to the own page.

  • That's an awesome quality plugin. First some features of it didn't work for me, but there was a conflict with some of the theme's related js files, so good to check them first if you have any problem with the plugin. Aug 29, 2021 at 23:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.