Custom Posts Hierarchy? (State/City/Restaurant)

Question:

What is the best way to create a hierarchy structure (also called parent/child relationships) between custom post types?

For example, we currently have 3 post types: States, Cities, and Restaurants. Each Restaurant will be in a city, and each city will of course be in a state. So for example, Joe’s Crab Shack would be in the city of Orlando, which would be in the state of Florida. I understand taxonomy for the most part, but I’m not sure how to actually “set” the relationship between ex: Joe’s Crab Shack/Orlando, and Orlando/Florida. Is this done through taxonomy as well, a custom field type, etc? We also plan on importing these through an Excel document.

Structure Example:

  • URLs: www.site.com/florida/orlando/joes-crab-shack/
  • Breadcrumbs: state->city->restaurant

Pages (only need to know how to retrieve the results):

  • State pages should be able to list all of their cities.
  • City pages should be able to list all of their restaurants.

0

Leave a Comment