I am working on a site that highlights neighborhoods.
Within each neighborhood there are places (that will be added by the client on the back end).
Each neighborhood will have its own unique set of places.
I figured out how to lead a list of all neighborhoods (neighborhood.php) to it’s specific single neighborhood (single-neighborhood.php).
However once i get into a single neighborhood i don’t understand how to create a link to a list of places (which would be a Custom Post Type) that would then link to their single place page.
I was considering using the concept of creating a Places Custom Post Type and then a single-place.php page template but i’m wondering how WordPress would interpret that and how it would lead to the correct post.
Here is an image that shows the heirarchy, i have completed levels 1 through 3 and am trying to figure out 4-5.
I know how to create Custom Post Types, I know how to make custom fields, I know how to connect the custom fields to templates.
What i don’t know and am trying to figure out is how to link to the single places from a specific neighborhood?
How does wordpress understand what Place post to go to?
In Summary I:
- Created 27 neighborhoods
- Each neighborhood has a sub navigation that leads to “Places” “History” “Gallery” “Points of Interest”
- I need to figure out how to link a list of Places to the “Places” sub nav link and have it pull the content from a specific Place Custom post and then have that list lead to a single place page
I understand the concept of neighborhood.php template permalinking to single-neighborhood.php but i don’t get how to make a further nested site heirarchy work under this logic would it still be place.php to single-place.php?
If so how do i link to a list of places relevant to specific neighborhoods within the single-neighborhood page?
Thank you.
There are three ways you can go about this:
Personally, I would go with (2). If you decide to go that route, it would be as simple as
taxonomy-neighborhood.php
While this does have some data redundancy (individual neighborhoods will be both posts in a post type as well as terms in a taxonomy), that’s rectifiable. The key to making this work well is convention over configuration: make sure that all the neighborhood slugs are identical in the post and term.
If it were me, I would then hook into the save_post process and make it so that any time a neighborhood is added or its slug edited, a term is also added or edited behind-the-scenes. I would also remove the term pages from the admin panel so the editors can’t add/edit the terms, and only have access to the posts.