Skip Navigation

[Resolved] Best Practices for Listing Custom Post Type in Hierarchical List

This support ticket is created 5 years, 9 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Karachi (GMT+05:00)

This topic contains 2 replies, has 2 voices.

Last updated by laneV 5 years, 9 months ago.

Assisted by: Waqar.

Author
Posts
#1217129

I have a custom post type for places. I'd like to associate each post by up to 3 geographical regions (country, state, region). I'd like to be able to list them out in a bullet list like:

* Country 1
> State 1
- Place 1
- Place 2
> State 2
- Place 3
etc....

I've looked through the forums with people asking for workarounds. I've tried with hierarchical taxonomy but that doesn't seem to work well with more than 2 levels. I've thought about post relationships but not sure they would work much better. I've thought about custom shortcodes to query by region and hard code the display for Country and State then list out the Places in each Region but I think that may end up being heavy on the DB with a ton of queries.

Rather than asking how to make it work with how I'm trying to do it, I'd like to ask if the Toolset team has a best practice they'd recommend for how I should do it.

Thanks!

#1217968

Hi Lane,

Thank you for contacting us and I'll be happy to assist.

Your observation is correct and there are more than one ways to connect multi-level objects (eg. Countries > States > Places ).

But in my experience, using post-relationships has its advantages, over other approaches.

Which means that Countries, States, and Places can all be added as custom post types and then linked to each other through one-to-many relationships.

1. Countries will have a one-to-many relationship with the States
2. States will have a one-to-many relationship with the Places

This approach will allow you to use search filters in Toolset Views and fields in Toolset Forms, in a natural hierarchal way, without any additional customization or workaround.

I hope this helps and please let me know if you need any further assistance around this.

regards,
Waqar

#1220097

Thank you for the advice! I'll work with that. Much appreciated!