Site icon Hip-Hop Website Design and Development

Virtual page and loading template

Lately have been trying to create a page with a set of data based on the page name.
Creating the template has been easy but I have trouble knowing how to make an URL trigger a page with a template while the page doesn’t exist in the database.
and the template must be based on the parent page.

for example:

https://www.example.com/parentpage1/virtualpage

will trigger the first template and load a page that doesn’t exist

https://www.example.com/parentpage2/virtualpage

Will do the same but with a different template

Getting those pages indexed would be fixed with a script that adds the URLs necessary to the sitemap which I have done before.

Does anyone know how to approach such project and what kind of documentation I would need to figure this out?

I haven’t found the specific answer I needed without plugins