Skip Navigation

[Resolved] Display Data in a table from multiple post types

This support ticket is created 4 years, 11 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 40 replies, has 3 voices.

Last updated by Christian Cox 4 years, 9 months ago.

Assisted by: Christian Cox.

Author
Posts
#1466087

Tell us what you are trying to do?
I have created 2 custom post types
(1) Players

Player Name - post title
Sex
Club
Coach
Age Group
Player Photo
Player Gender
Player Summary

(2) Event

Event Name(e.g U16) - post title
Player Position
Player Performance
Event Date
Event Venue
Event Meeting

I used many-to-many to connect players to events and I want to render in a table format as below using views and I can't seem to find how to display data from both post types

(1) Rank (2)Player Performance (3) Personal Best (4)Player Name (5)Coach (6)Club (7)Event Venue (8)Event Date

Is there any documentation that you are following?
https://toolset.com/documentation/post-relationships/how-to-set-up-post-relationships-using-toolset/

Is there a similar example that we can see?
hidden link

What is the link to your site?
yfldubai.com

#1467977

I used many-to-many to connect players to events and I want to render in a table format as below using views and I can't seem to find how to display data from both post types
Hi, it sounds like each Player can be connected to many Events. Since this is the case, which Event's details would be displayed in this table? Is it the most recent Event for each player, or is a table produced for every Event?

I see you mentioned Player Position and Player Performance as information in the Event post type. However, it seems like this information will be different for each Player in each Event, correct? If so, then these two fields must be applied to the intermediary post type, not the Event post type. This will allow different position and performance information for each Player in each Event.

To start this display, I would create a table View using the Players post type in the Content Selection. When creating the table using the Loop Wizard, insert some placeholder content for now if the content is in another post type. This will allow you to get the main table structure created, then you can modify the contents of each cell later.

To display information from the Event post in one column of the Player table, you must create a View of Events filtered by post relationship, where the related Player is the current post in the loop. You must use ordering, limit, and filtering to determine which Event's information will be displayed in this column. Insert the information you want to display from this Event in the Loop, then insert this View in the Players table in the column of your choice. Repeat this process for each column that contains information from the Events post type. I hope this makes sense. If you have questions or need more guidance, feel free to let me know and I can give you more feedback.

#1468757

I don't understand can you please explain further.

This what I want to achieve with the view

1. Users should be able to select using the filter to filter the events, age group, gender
2. The view will display the below data in a table form based on the filter options

(a) Rank -(this is just numbering the output from 1 till the last item in the result)
(b) Player Performance - (from events custom post type for that player)
(c) Player Name - (from players custom post type)
(d) Coach - (from players custom post type)
(e)Club - (from players custom post type)
(f)Event Venue - (from events custom post type for that player)
(g)Event Date - (from events custom post type for that player)

#1469947

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Ademola,

Christian is currently on holiday today but will be back tomorrow to continue this ticket with you.

Thanks you for the continues patience.

#1471483

Hello,

Still waiting for your response on this.

#1471845

Okay would you like to collaborate on a View so you can see what I mean in a practical setup? I can set something up in our sandbox site at https://discover-wp.com if you sign up for a free account there. I will begin creating that now. If you sign up using the email address associated with your account, I can send you an invitation.

#1472333

Hello, yes I would love to collaborate. I have signed up on discover-wp.com with the email associated with my support account. You can send the invite. Thank you.

#1473159
Screen Shot 2020-01-22 at 8.56.58 AM.png

Okay perfect, please check your email for an invitation link. I have set up two custom post types: Events and Players. There are some other pages and post types used as demo content, but you can disregard those. We will work with Events and Players. I have also added a many-to-many relationship between Events and Players, as discussed. You can see that relationship here:
hidden link

Next, I suggest you set up all the custom fields for Players, Events, and the relationship / intermediary post type. I suggest you add Player Performance and Player Position fields in the intermediary post type. When you add these custom fields in the relationship / intermediary post type, this allows you to set Player Performance and Player Position for each Player, per Event. In other words, Player 1 can be in the position of Forward at Event 1, but also in the position of Midfielder at Event 2. Similarly, Player 1's performance at Event 1 can be "excellent", but at Event 2 it can be "poor". This is just an example, your values will be different but I hope this clarifies.

You can add the Player Performance and Player Position fields to the intermediary post type at the link I shared above. See the screenshot here showing where you would add fields to the intermediary post type. After you have your custom fields set up, you can create some Events and some Players. When you connect Events and Players using a post relationship, you will be able to set the values for Player Performance and Player Position. I hope this is clear, let me know if you have questions about the suggestions here and I can try to explain in more detail.

#1473391
events.PNG

I have added custom fields and taxonomies to the player's post type but I can't find the events custom post type in your setup. (see attached). In addition, the player performance and position are recorded similar to those in a sports competition e.g in a 100m race performance will be the time(e.g 5:44s) each player completed the race and position will be the position the player finished the race(e.g 1st, 2nd, 3rd etc)

#1473519
Screen Shot 2020-01-22 at 11.02.57 AM.png

I have added custom fields and taxonomies to the player's post type but I can't find the events custom post type in your setup.
I think you're confusing the Events custom post type with a custom field group. The Events custom post type exists already (see the main site menu screenshot here) but there is no custom field group assigned to it yet. You can click "Add New" at the top of the Custom Field Group page, then click "Post fields" to create a new field group. In the "Appears on" section, assign the field group to the Events post type. Then begin adding your fields for Events in that field group.

#1473543

okay. I have done that. What should I do next?

#1473547

Okay great, if you have all your custom fields set up, you can begin adding a couple of test Event posts and a few test Player posts. Then you can connect Players and Events using the post relationship I have set up. When you create or edit an Event or a Player, you will see a post relationship editor panel. There you can choose from existing posts, or you can create new posts right in the relationship panel.

Next we will work on a View showing the Players associated with one specific Event you have set up. Let me know when you are read to proceed with that.

#1474889

Hello, I have added some players and some events. I guess we can go on to the view part.

#1475177

Okay I'm working on this now and will update you shortly.

#1475193

Okay I set up a template Layout for Events, then I created a View of Players with a post relationship Query Filter. I placed that View in the layout, so you can now see a table on each Event page. Let's look here for an example:
hidden link
Is Rank directly based on Player Performance, or is there some other ranking system? I'm not sure how to sort the table so that the rank is accurate.