Redirect page without changing the url

I have a page running a custom shortcode. When an element on the page is clicked I am pushing a new url into the browser (using history.pushstate) and displaying the content in the same window.

If this url is copied and pasted at a later date into the browser, I want to be able identify this and display the content. As the requested element is not actually a real page/post, I am having difficulty. I can use template_redirect hook to identify if it is the link I am interested in, and I can forward the page - but I don't want to forward, I want to keep the url but load a specific page.

Is there a way of doing this?

Topic template-redirect Wordpress

Category Web


This can be achieved using a Virtual Post. See this link on how to do it. https://ashiqur.com/how-to-add-a-virtual-page-in-wordpress/

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.