Skip Navigation

[Resolved] Create view of all staff related to parent department and parent dept children.

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.

Our next available supporter will start replying to tickets in about 2.43 hours from now. 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/Karachi (GMT+05:00)

This topic contains 1 reply, has 2 voices.

Last updated by Waqar 7 months, 1 week ago.

Assisted by: Waqar.

Author
Posts
#2625463

Tell us what you are trying to do?

I have a custom post type called departments, which is a hierarchical post type. I also have a custom post type called staff, which can be in a many to many relationship with departments. For example, Wilson Library is a parent department, and University Archives is a child department of Wilson Library.

I would like to create a view that shows staff members related to Wilson Library, as well as staff members related to one of its child departments.

Is there any documentation that you are following?
I was unable to locate documentation.

What is the link to your site?
Site is in development and not currently shareable.

#2625575

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi,

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

To achieve this you'll need to use two views. One for cycling through the the target 'departments' posts and the other for showing their related 'staff' posts.

And since we'll need to nest the second view inside the first one, it will only be supported through the classic/legacy editor views.

If you haven't enabled them, please go to WP Admin > Toolset > Settings > General and select the option "Show both the legacy and Blocks interface and let me choose which to use for each item I build" for the "Editing Experience".

After that, you'll see the option to add classic views from WP Admin > Toolset > Views. You'll find the documentation on using the classic views at:
https://toolset.com/documentation/legacy-features/views-plugin/

I'll especially recommend going through the guides on filtering views by post IDs and nesting them:
https://toolset.com/documentation/legacy-features/views-plugin/filtering-views-query-by-post-id/#value-set-by-view-shortcode-attribute
https://toolset.com/documentation/legacy-features/views-plugin/using-a-child-view-in-a-taxonomy-view-layout/

In summary, the first parent view will be set to show the 'departments' posts, with a post ID query filter to specify only selective 'departments' posts.

And in the loop of this parent view, a second child view will be nested that will be set to show the 'staff' posts, with a relationship query filter so that only the related posts of the current parent 'departments' post are shown.

I hope this helps and please let me know if you have any follow-up questions.

regards,
Waqar

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.