2

The website uses -

A) A hierarcical Custom Post Type "Destination" to support the following structure, so each tier of the hierarchy could have its own unique destination guide:

  • Territory - Americas
  • Continent - North America
  • Section -
  • Country - United States
  • Region -
  • State - New York
  • Area -
  • City - New York City
  • District - Manhattan
  • Neighborhood - Upper East Side

Resulting in the Upper West Side destination guide having 7 tiers and the URL:

site.com/destination/americas/north-america/united-states/new-york/new-york-city/manhattan/upper-east-side/

Note that each tier of the hierarchy is not required to be populated - a second example would be the destination guide for the Caribbean island of Dominica, which would only require four tiers:

  • Territory - Americas
  • Continent - North America
  • Section - Caribbean
  • Country - Dominica
  • Region -
  • State -
  • Area -
  • City -
  • District -
  • Neighborhood -

The URL for the Dominica destination guide would be:

site.com/destination/americas/north-america/caribbean/dominica/

No issues here - that part works fine. Here is the challenge -

B) Each individual destination has a variety of unique features that have their own respective Custom Post Type:

  1. Hotels
  2. Restaurants
  3. Bars
  4. Attractions
  5. Tours
  6. etc.

These Custom Post Types are not hierarchical, but must be related to the appropriate page (tier) of a Destination Custom Post Type.

To provide logical consistency between the site architecture, permalink structure, breadcrumbs and menus, each of these Custom Post Types should be listed under a specific destination.

The various Custom Post Types for these destination features are simple and not hierarchical.

Hotel Example: An individual hotel would have a simplistic hotel/hotel-name structure, but always be associated with a parent destination.

As a result, the Permalink for The Lowell Hotel on New York's Upper East Side would be:

site.com/destination/americas/north-america/united-states/new-york/new-york-city/manhattan/upper-east-side/hotel/the-lowell/

In Dominca, the hotel Permalink/URL would be:

site.com/destination/americas/north-america/caribbean/dominica/hotel/rosalie-bay-resort/

Restaurant Example: The same approach would hold true for a restaurant, in this case, the Serafina Restaurant:

site.com/destination/americas/north-america/united-states/new-york/new-york-city/manhattan/upper-east-side/restaurant/serafina/

Again, for Dominca, a restaurant Permalink/URL would be:

site.com/destination/americas/north-america/caribbean/dominica/restaurant/romance-cafe/

By using this approach, a number of taxonomies may be added to query/filter, for example, four-star, resort hotels, under 250 rooms, with guest ratings over 7/10, with the Destination (and its child destinations) defining the eligible properties.

Ideally, would like to deal with this using rewrite rules to subordinate the otel, Restaurant, etc. Custom Post Types under the Destination Custom post type.

Have tried it a number of ways with no success. Any suggestions? Examples would be much appreciated.

  • there are 2 parts to this problem. first- rewrite rules to catch incoming requests. could probably solve this without having to write the rules yourself by adding rewrite endpoints, hooking pre_get_posts, and manipulating the query to grab whatever hotel/restaurant/etc, is requested. the 2nd part is generating the URLs, so the_permalink() outputs the correct parent destination in the URL. For that you'll need a UI solution to associate one post type to the other via a metabox, and a hook on post_type_link to build the URL. that's the best I can do on a friday night :) – Milo Jul 19 '14 at 3:02
  • Thank you Milo - I am fairly sure that I have Part 2 handled, but Part 1 is still giving me problems. Could you possibly provide a bit more detail on how to add the rewrite endpoints, hook pre-get-posts and manipulate the query? I would love to handle it without having to write the rewrite rules. – RobertKCole Jul 26 '14 at 19:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.