Page URL with forward slash and same subpages for parent

I would like to set up a URL scheme that uses the parent URL locations and a subpage of each location with name and ID passed in together as one page. Here is an example of how I would like it to appear:

In the example, locations is the parent landing page with nyc as the location name and 1 as the ID. However, I am having trouble figuring out how to set up nyc/1 as one page as WP removes the forwarding slash and combines them into nyc1.

The reason I would like to set it up this way is to parse the url and display a template using data for that location only. I could do this using only ID, but it would be user-friendly to include location name in the URL as well.

Following this, is it possible to load a default set of subpages for each of these locations? For example, each location has an hours subpage and a contact subpage.

Would I need to make an individual subpage of hours and contact for every location or can I load them by default based on the fact that they are subpages of the location parent? As in, for every locations subpage, give them the same sub-subpage by default when created.

This might be confusing, so if anyone has advice on how to set something like this up it would be a huge help. Do I look toward custom post types? URL rewriting?

Read more here: Page URL with forward slash and same subpages for parent

Leave a Reply

Your email address will not be published. Required fields are marked *