Tell us what you are trying to do?
I have a custom post types LAKES which have 'Locations' categories that are hierarchical in nature.
For example:
Lake Ashmere (hidden link) is located in the western tourism region of Massachusetts USA, so it has 4 assigned categories/taxonomies:
- USA [the country]
-- New England [the region of the country]
--- Massachusetts [the state in that region of the country]
---- Western [the tourism region of the state of Massachusetts]
I'm trying to create a View that displays at least 3-6 of the nearest lakes to the current lake post being displayed. On this page, you'll see I've created the View titled 'Explore more lakes nearby' with a Taxonomy query filter that is 'Set by the current post in the loop'. The results I'm getting is basically a huge list of all lakes that have ANY of the same taxonomies (so essentially its showing all the lakes in the same top level country location).
I cannot figure out how to only include the most closely related posts, based on category hierarchy. At least the smallest tourism region, but would also love to include the next one up (a state in this case) if there are not enough lakes in that one.
Also, not all lakes have the same amount of categories assigned. Some lakes in other countries only have a parent-child-grandchild, or some only have parent-child. So I'm not sure this is even the best way to display what I am after. Maybe assigning each lake a custom field of some sort and use that to display would be better?
What is the link to your site?
hidden link
Hi there,
In my humble opinion having a Location hierarchal taxonomy is not a good segmentation of data and will limit you if you plan to expand on the data.
I would even avoid having them added as custom fields. The states and cities and counties have separate characteristics that qualify them to have a separate custom post type for each. Then you can use the relationship between the posts and your data to connect between them and create any kind of filter that you want.
We have a Real State sample that you can install on a sample WordPress installation to get to know the details on how to implement such a relationship between the hotels and the location.
I suggest that you check the reply below from my colleague who explained this beautifully:
https://toolset.com/forums/topic/best-way-to-organize-content-by-location-state-county-city-across-post-types/#post-1643155
You can get started with post relationships here:
https://toolset.com/documentation/post-relationships/how-to-set-up-post-relationships-using-toolset/
Thanks.