Skip Navigation

[Resolved] hierarchy problem

This thread is resolved. Here is a description of the problem and solution.

Problem:

I am trying to create a hierarchy in three levels

Level 1
/property-for-sale

Level 2
/property-for-sale/spain
/property-for-sale/madrid
/property-for-sale/valencia
/property-for-sale/nice

Level 3
/property-for-sale/madrid/apartment-in-serranos
/property-for-sale/madrid/apartment-in-la-moraleja
/property-for-sale/nice/mont-boron
/property-for-sale/nice/cimiez

I have tried to build this using both taxonomies and custom post types but do not manage to get it to work properly

Ideally, I would like it to work as follows

Level 1 and level 2 are both archive pages
However, the archive pages should only
- include children one level down
- and only those children that belong to a certain taxonomy
E.g, of the four level 2 examples above, only the following two belong to the ‘for sale’ taxonomy
- /property-for-sale/spain
- /property-for-sale/france
Consequently, on the ‘/property-for-sale’ archive page should only these two sections immediately above appear.

Solution:

There isn't such a built-in feature within Types plugin, but you can setup such kind of permalinks with only one "hierarchical" custom post type, just like the wordpress built-in post type "Page", for example:
1) You can create a custom post type "property-for-sale" with Types plugin
in section "Sections to display when editing ", enable option "Page Attributes",
in section "Options", enable option "hierarchical"
Then you will get a "hierarchical" custom post type
More help:
https://codex.wordpress.org/Function_Reference/register_post_type#rewrite

2) Then create a view to query the child posts, and display this in the level 1 and level 2 posts

Relevant Documentation:
https://toolset.com/documentation/user-guides/filtering-views-query-by-post-parent/

This support ticket is created 6 years, 10 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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

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/Hong_Kong (GMT+08:00)

This topic contains 9 replies, has 2 voices.

Last updated by Luo Yang 6 years, 10 months ago.

Assisted by: Luo Yang.

Author
Posts
#604826

Hello,
Great if you can provide some guidance regarding the following.
I am trying to create a hierarchy in three levels

Level 1
/property-for-sale

Level 2
/property-for-sale/spain
/property-for-sale/madrid
/property-for-sale/valencia
/property-for-sale/nice

Level 3
/property-for-sale/madrid/apartment-in-serranos
/property-for-sale/madrid/apartment-in-la-moraleja
/property-for-sale/nice/mont-boron
/property-for-sale/nice/cimiez

I have tried to build this using both taxonomies and custom post types but do not manage to get it to work properly

Ideally, I would like it to work as follows

Level 1 and level 2 are both archive pages
However, the archive pages should only
- include children one level down
- and only those children that belong to a certain taxonomy
E.g, of the four level 2 examples above, only the following two belong to the ‘for sale’ taxonomy
- /property-for-sale/spain
- /property-for-sale/france
Consequently, on the ‘/property-for-sale’ archive page should only these two sections immediately above appear.

And when clicking to ‘/property-for-sale/spain’ the archive page should only show the following two (as they belong to the ‘spain’ taxonomy)
/property-for-sale/madrid/
/property-for-sale/Valencia

Finally, clicking to ‘/property-for-sale/madrid/’, the archive page shows only the following details ( as they belong to the madrid taxonomy)
/property-for-sale/madrid/apartment-in-serranos
/property-for-sale/madrid/apartment-in-la-moraleja

And when finally clicking any of the two links above, you are taken to a property description page.

The above structure should be visible on a mega menu.

If you can help, it would be absolutely fantastic. Please do let me know if you need any further info

Looking forward to hearing from you.

#604950

Dear John,

There isn't such a built-in feature within Types plugin, but you can setup such kind of permalinks with only one "hierarchical" custom post type, just like the wordpress built-in post type "Page", for example:
1) You can create a custom post type "property-for-sale" with Types plugin
in section "Sections to display when editing ", enable option "Page Attributes",
in section "Options", enable option "hierarchical"
Then you will get a "hierarchical" custom post type
More help:
https://codex.wordpress.org/Function_Reference/register_post_type#rewrite

2) Then create a view to query the child posts, and display this in the level 1 and level 2 posts
More help:
Filtering Views Query by Post Parent
https://toolset.com/documentation/user-guides/filtering-views-query-by-post-parent/

#606052

Hi, thank you for following up. I have been out of the office all week so have not had a chance to test your advice. Will check beginning of the week and let you know if all works so great if you could leave the ticket open for a few more days.
Kind regards / john

#606134

OK, please update this thread if you still need assistance for it.

#606589
attachment-3.jpg
attachm1.jpg
attachm-2.jpg

Hi, Thanks for keeping the ticket open.
The remaining problem I have is as follows
I have created the custom post type 'properties for sale'
Here I have created a two level structure - see attachment 1
The first level, ie '/properties for sale' show the intended archive layout (Layout for Property for sale Archives)
But
How can I get the next level, ie /properties for sale/barcelona' to also show the archive layout (see attachment 2) while level three, ie ie /properties for sale/barcelona/xxxxx' should display the page layout (see attachment 3)
Secondly, I made a mistake when describing the search flow in the first message.
The archive pages for the first two levels ('/properties for sale' and /properties for sale/barcelona' should both display links to level three pages - /properties for sale' display an archive page with all properties for sale while /properties for sale/barcelona' should only displays properties for sale in Barcelona.
Hope you can help.
Best regards / john

#606621

Q1, How can I get the next level
As I mentioned above, you can create a view to display the child posts, see our document:
Filtering Views Query by Post Parent
https://toolset.com/documentation/user-guides/filtering-views-query-by-post-parent/

Q2, The archive pages for the first two levels ('/properties for sale' and /properties for sale/barcelona' should both display links to level three pages
For the " /properties for sale/barcelona", please check the answer above Q1)
For the "/properties for sale", it will need a nested view:
- parent view list child "properties for sale" posts of current page, filter by:
Select posts whose parent is the page where the View is shown.
- Child view list child "properties for sale" posts of current post, filter by:
Select posts whose parent is the current post in the loop.

#608816

Apologies - I got sidetracked by another project.
Final question before closing - can you please forward a link to a page that describes how to display a 'view' the level 1 and level 2 posts and I should be able to take it from there.
Many thanks / john

#609162

You just need to put the shortcode of child view into the loop of parent view, more help:
https://toolset.com/documentation/user-guides/using-a-child-view-in-a-taxonomy-view-layout/

#609256

OK, many thanks for your help.
Closing the ticket.
Best regards / john

#609596

You are welcome