Hi Guys, just wondering if the following is possible using the Types plugin?
I need to somehow do the following:
Add types of Country, City and Airport
Make a hierarchy of Country > City > Airport (i.e you can only add a city to a country and an airport to a city etc)
Make the URL reflect this:
Country: /united-kingdom
City: /united-kingdom/london
Airport: /united-kingdom/london/heathrow
Could someone let me know if this is possible with this plugin?
Many thanks,
Dave
Dear daveH-2,
Yes, I think so. The whole environment should be:
- To create 3 custom post types
- Assign Country as parent of City and City as parent of Airport
- In the Advanced section of all custom post type config page you need to check the "hierarchical" option
Please take a read here: https://toolset.com/documentation/user-guides/creating-post-type-relationships/
Please let me know if you are satisfied with my answer and if I can help you with any other questions you might have.
Hi Adriano. Thanks for your reply.
I did try what you said previously, but ideally I need it to not allow a city to be added without selecting a parent country. When adding a city, I couldn't even see a way to select the parent - should I be able to?
Also can the URLs be adjusted to take the hierarchy into account, i,e: /united-kingdom for a country, /united-kingdom/london for a city and /united-kingdom/london/heathrow for an airport?
Many thanks,
Dave
Dear daveH-2,
Unfortunately that's a limitation from WordPress. If you are creating a post and need to set a parent that is from other custom post type, first you need to save the child and then you are able to select the parent.
We have another solution in cases like this (I think that's not for you because you needs 3 level of relationship) that is hide the child custom post type from our GUID (it doesn't appear on left admin menu) and only can add it in the country page (child fields section). The problem is that you can't do this for City > Airport because the City custom post type doesn't appear on admin menu.
If you set hierarchical option In the Advanced section of your custom post type edit page, the URL should be hierarchical.
Please let me know if you are satisfied with my answer and if I can help you with any other questions you might have.
Thanks Adrian,
I have it set up how I need it to be in the admin so all good there. The URLs I have enetered as I require in in wp_posts guid field.
Is there any way I can make the plugin use the guid rather than doing it's own URL?
Many thanks,
Dave
Dear daveH-2,
You can change the WordPress permalinks format in Settings > Permalinks. The default option is the GUID.
Please let me know if you are satisfied with my answer and if I can help you with any other questions you might have.