Skip Navigation

[Resolved] Displaying a grid of posts with fields from a post connected via a relationship

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

Problem: I would like to create a grid of posts. In each item, I would like to show information about the post, and I would also like to show information about a related post, using Relationships. I set up a View but it shows "No items found".

Solution: Remove the Post Relationship filter from this View, so that the main grid results are not filtered. Use the Fields and Views button above the Loop Output editor to insert shortcodes that will display information about the current post in the loop, or about a post related to the current post in the loop.

Relevant Documentation:
https://toolset.com/documentation/post-relationships/how-to-display-related-posts-with-toolset/

This support ticket is created 6 years, 6 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
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 4 replies, has 2 voices.

Last updated by josephQ 6 years, 6 months ago.

Assisted by: Christian Cox.

Author
Posts
#914261
Screen Shot 2018-06-16 at 16.08.18.png

Tell us what you are trying to do? I have two types of posts: a project post and an author post. They are connected to each other via a post relationship. I'm trying to display a grid of the projects which also lists the author of each project. Please see the attached screenshot.

Is there any documentation that you are following? No.

Is there a similar example that we can see? No.

What is the link to your site? Here is a small grid of posts that does not contain any author information:
hidden link

#914470
Screen Shot 2018-06-17 at 3.50.54 PM.png
Screen Shot 2018-06-17 at 3.49.56 PM.png

Hi, you can use the Fields and Views button above any text editor area to insert a custom field, and use the "Post selection" tab in the popup to specify which post contains the field. There is an option in the popup to select a post that is related to the current post, and you can choose which post relationship you want to query in.

Let me know if I've misunderstood what you want to accomplish.

#914996
query filter.png
loop editor - loop wizard.png
content selection.png

Christian,

Thanks for responding. It appears that your instructions are intended for a one-off, or manual, index. I'm trying to create an automatic index using a View (which I think is the correct approach) that's connected to the layout for the index of projects (a project is named a "Thesis Work" in my instance of WP).

In the View, under Content Selection, I've selected "Thesis Works" (see content selection.png).

In the Query Filter area, the View is connected via the "alumni thesis work" relationship (see query filter.png).

In the Loop Editor, the dialogue is referencing four fields: Index Thumbnail (belonging to the Thesis Work CPT), Post Title (belonging to the Thesis Work CPT), First Name (belonging to the Alumni Bio CPT), and Last Name (belonging to the Alumni Bio CPT). See loop editor - loop wizard.png.

What I see on the front-end (hidden link) is the message "No items found." I am expecting to the grid of posts which I'd defined as two columns wide and however many rows as needed.

Does this make sense?

#915293

It appears that your instructions are intended for a one-off, or manual, index.
The instructions are intended for use inside the Loop Output of a View. The Loop Output of a View is responsible for creating the list (or grid) of results. When you place your cursor in the Loop Output editor, inside the wpv-loop tags, you can insert information from the current post in the loop, AND information from a post related to the current post in the loop. You do this by clicking "Fields and Views" above the Loop Output editor and inserting shortcodes into the Loop Output editor content. These shortcodes have attributes that tell the Loop which custom field or post information to display. You can set the shortcode to get information from the current post in the loop, or to get information from a post related to the current post in the loop using the process I described earlier.

In the Query Filter area, the View is connected via the "alumni thesis work" relationship (see query filter.png).
You want the results to be a grid of Thesis Work Posts, correct? Then inside each of those grid items, show some information about both the Thesis Work Post and its related Author, correct? If so, then there is no need for a Post Relationship filter here, because you don't want to filter the grid of Work Posts - all Work Posts should appear in the list, not only those in a specific relationship. So I think this Query Filter should be deleted.

In the Loop Editor, the dialogue is referencing four fields: Index Thumbnail (belonging to the Thesis Work CPT), Post Title (belonging to the Thesis Work CPT), First Name (belonging to the Alumni Bio CPT), and Last Name (belonging to the Alumni Bio CPT). See loop editor - loop wizard.png.
When you use the Loop Wizard to construct the loop, this popup dialog doesn't give you the ability to select the post reference. In other words, the fields you add in the popup are all assumed to be applied to the current post in the loop. Since you also want to display some information from a post related to the current post in the loop, some additional work is required. Do not include any field in the Loop Wizard that should be shown from a related post, only include fields that are in the current grid item post. Then after the Loop Wizard inserts the generated code in the Loop Output editor, you can use the process I described before to insert any field from a related post with the Fields and Views button.

What I see on the front-end is the message "No items found."
This indicates that your Query Filter is causing the View to have no results. See above - I think you should delete this Query Filter.

#915481

This is exactly what I needed to know. Looks like the post relationship in the query filter was unnecessary, and now I've got it working (at hidden link). Thank you, Christian!