Skip Navigation

[Resolved] Displaying relationship data from unrelated custom post type

This support ticket is created 5 years, 3 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
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+01:00)

This topic contains 2 replies, has 2 voices.

Last updated by sallyD 5 years, 3 months ago.

Assisted by: Nigel.

Author
Posts
#1539693

I have 3 custom post types:
Students
Training Courses
Companies

I have 2 relationships set up:
Students <<Attendances>> Training Courses - this is to track which courses students have completed.
Companies <<Company Employees>> Students - this is to record which students belong to which company

I am trying to:

Display a list of courses that an individual student has completed on a Companies (single) content template.

Example: hidden link

To insert the list I have created a view called 'list-of-students-completed-training-courses' but the result is No items found.

Is it possible to display the course information given that the Attendances intermediary post type is not related to the Companies post type?

I am happy to supply a log in to the website.

Thanks

#1540201

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+01:00)

Hi Sally

You are starting at companies and want to display courses.

companies    students    courses
         \  /        \  /

You can't leapfrog all the way in one go, you need nested Views.

Starting from your template for companies, your first View queries students (with a post relationship query filter to connect it to the company where this View is shown), and in the output section of this first View—which is returning student posts—you insert a second View, this time querying courses, with a post relationship filter to connect it to the current post in the outer loop.

If you've been trying out the new blocks editor for Views you should be aware that support for nested Views isn't included yet, you'll need to persist with the classic Views editor.

#1543873

My issue is resolved now. Thank you!