Taxonomy Sub Pages
- This topic has 3 replies, 2 voices, and was last updated 4 years ago by
Long Nguyen.
-
AuthorPosts
-
January 22, 2022 at 1:57 AM #33384
shmaltz
ParticipantI am working on a travel site, and there is a CPT called Listings with a taxonomy called Destinations.
The Destinations taxonomy is hierarchical and looks like this:
Country->State->CityWe have another taxonomy called Categories that contains the categories of listings, such as Restaurants, Parks, Beaches, etc.
What we want to do is programmatically create a sub-page under each City for each Category that the city has a listing post in.
E.g. If the city Albany has listings in the Restaurants, Parks and Airports categories, I want the site structure to look like this:
USA->New York->Albany->Restaurants or
USA->New York->Albany->Parks or
USA->New York->Albany->Airports etc.(We don't want to manually add Beaches, Restaurants etc. as a child taxonomy of destinations).
Is this possible to do using 1 CPT?
Or should we create 2 CPTs (one for all the places and another one for the listings?
Or should we use an entirely different method of organizing all this data?An example of the URL format we are looking for is over here: https://www.trailforks.com/region/new-york/
(Click on the tabs on top, Overview, Areas, Trails, Routes etc. and see how there is a sub-page. Each State has these sub pages)Thanks!!
January 22, 2022 at 10:13 AM #33392Long Nguyen
ModeratorHi,
You can use 1 CPT for that structure. You also need to use the extension MB Relationships to create a relation between two taxonomy Destinations and Categories. In each term City, you can create connections to term Restaurants, Parks, Airports ...
https://docs.metabox.io/extensions/mb-relationships/January 23, 2022 at 11:02 AM #33410shmaltz
ParticipantThank you, but I'm not sure I understand you.
How will this allow me to have a link structure like this:
Country->State->City->Restaurant->post_titleDo I have to do anything besides add the relationship? Do I need to make this relationship on each post?
Thank you
January 24, 2022 at 2:53 PM #33426Long Nguyen
ModeratorHi,
If you want to create the custom permalink structure like that, please refer to this topic https://stackoverflow.com/questions/41494883/show-only-specific-categories-in-permalinks-for-custom-post-type-in-wordpress/#answer-41654620
-
AuthorPosts
- You must be logged in to reply to this topic.