Skip Navigation

[Resolved] Using View blocks to set up Relationship queries

This support ticket is created 5 years 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.

This topic contains 2 replies, has 1 voice.

Last updated by nicholasG-2 5 years ago.

Author
Posts
#1483131

Hey there,

I'm hoping you guys can help! I'm becoming a big fan of using Toolset to develop data-driven sites for our clients, but I've finally run up against a wall. We're building a site that has a database of award winners. I've got 2 custom post types connected in a M2M relationship, with an intermediary post. Here's the data:

PARENT - Award Category
CHILD - Award Nominee
INTERMEDIARY - stores data: AWARD WON (boolean), and AWARD YEAR (number)

When I try to display a list, whether listing all awards by YEAR, by CATEGORY, or by NOMINEE, I can generally only get 1 or 2 data points to show. Here's an example of what I'm trying to achieve:

Best Musical Director (single award category)
1987 - Bob
1988 - Julie
1989 - Ron

No combination of View settings will allow me to insert the YEAR data, in this example. I've followed the instructions on displaying posts connected by relationships, querying child posts, etc, but I can never get all fields to display. It's the same if I try to display the data in other arrangements (a single award nominee, for example, does the same exact thing).

Can someone give me a starting point here? I would love to be able to use Toolset's full....well, tools...and not have to code this into the theme.

Thank you for your help!!

#1483169
Capture.PNG

To clarify an issue with Views, an example:

While editing the Content Template for single Award Nominees.
- I've added the Field for post_title. All fine.
- I've then added a View to display Award Categories. I set the Query Filter to display posts related to that post, using the Award Categories/Award Nominees relationship. This is all fine.
-When I try to add the Award Year in the View (metadata attached to the relationship's intermediary post), the Intermediary post is grayed out and unselectable, so I can't display that data (See screenshot).
- I can add the Intermediary post (it's public) to the content query (so now it's Nominees AND the Intermediary selected), and now I CAN show the Award Year, BUT I'm also getting empty data in the query since it's also displaying the Intermediary posts, which don't need to be displayed on their own (and shouldn't).

Is there a way around this except for using conditionals, somehow? That seems quite inefficient, and queries more items than are necessary. Unless I'm wrong, in which case, correct me!

Thanks again.

#1483181

Nevermind!! Sometimes writing it all out makes it click. I figured out that if I query ONLY the intermediary post type, I can access everything I need tangentially. It's a different way of thinking than I'm used to, but it works.

Thank you again! And nevermind! 🙂