Skip Navigation

[Gelöst] Get name of related post

This support ticket is created vor 3 Monaten, 2 Wochen. 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.

Dieses Thema enthält 1 Antwort, hat 2 Stimmen.

Zuletzt aktualisiert von Nigel vor 3 Monaten, 2 Wochen.

Author
Artikel
#2732019

Hi there

We use relationships to connect two post types. On single pages this works well by displaying content related to the current post. However, if we want to use this in loops, it's not working. We would like to have something like this:

Loop of all teachers
> Each teacher is shown with name (= post title) and the classes they teach (= post title of the related posts)

As I said, for the single pages this works by using a content template. But as soon as we try to implement this with a view, we don't get any results. If we hardcode the post ID and add it as a shortcode parameter, it works. But for a loop this is not possible to implement.

We would like to use the name & related classes in a Avada loop or Revolution Slider element, we don't use the native Toolset blocks.

Can you tell me how I'd set up the structure of content template and view(s) so I can have them in our loops?

Thank you!

#2732039

Nigel
Supporter

Sprachen: Englisch (English ) Spanisch (Español )

Zeitzone: Europe/London (GMT+00:00)

Hi there

So, we are talking about a teacher, and displaying their linked classes via a View.

In the context of a single teacher, displayed via a Content Template, we would add a View to that template to loop over the connected classes. The View would need a Query Filter to specify that we wanted to show classes connected to the current teacher (which would be the page where this View is shown).

If you wanted a View of teachers, and for each of the teachers looped over it would similarly output the linked classes, you would need essentially the same set up, with a View to list the classes and a Query Filter to specify which teacher's classes to list, but in this case rather than "the page where this View is shown", the current teacher would be the current post in the loop (reflecting the context of the loop of the outer View displaying teachers).

If your Query Filter in that case is set to "the page where this View is shown", then that page is the page where the View is added, not a teacher post, hence I wouldn't expect any results.

Is that the issue you are having?

#2732228

Yes, thank you. I wasn't sure when to use a view or a content template. Your explanation helped me set this up correctly. It's working now.