I have a site which will show games played.
I have 4 teams available for selection using my form via a select (dropdown)
--Team 1 / Logo 1
--Team 2 / Logo 2
--Team 3 / Logo 3
--Team 4 / Logo 4
I want to create a template for a single page, however, I want the following output on my site;
Team Logo A | Team Name A - VS - Team Name B | Team Logo B
Team Logos replaced with a logo and Team Names replaced with Teams.
However, I want the logos to replace themselves dynamically and automatically, based on the selection.
Example:
Input -
If I select, Team 1 - VS - Team 4
Output -
Team Logo 1 | Team Name 1 - VS - Team Name 4 | Team Logo 4
Example 2:
Input -
If I select, Team 2 - VS - Team 3
Output -
Team Logo 2 | Team Name 2 - VS - Team Name 3 | Team Logo 3
Example 3:
Input -
If I select, Team 4 - VS - Team 2
Output -
Team Logo 4 | Team Name 4 - VS - Team Name 2 | Team Logo 2
Is this clear enough?
Is this possible?
I've thought about conditional outputs, but altogether I have 100+ teams in total and that would be a lot of code.
Unfortunately I think you'll have to use complex conditionals or come up with another way to store the data. For example, you could create a custom post type for Teams. The title of the post would be the team name, and you could use a custom field to store the team logo image. Then instead of using a custom field to select the team, you could use two post relationships to select the Team posts, like a Home team and an Away team post relationship. Then you could use Types and Views shortcodes to output the team names and team logos for each game played.
Hi Christian,
Thank you for the reply, I don't know if you understand what I am looking for completely.
I am looking at creating the game page using relationships.
I would need to create a new view for every single team.
On the left of the page would be first team, with all graphics and information relating to that team and on the right, another team, info, relating to that team.
But, am I able to select a view to show relationship 1, then another to select relationship 2?
Relationship 1 would be the Home team and relationship 2 would be the away team.
I would need to create a new view for every single team.
I don't think you'll need to create a new View for every single team, you need only two Views in the scenario I had in mind. Let's say you have one custom post type "Game" and another custom post type "Team". Create two many-to-many post relationships between Games and Teams - a "home team" relationship and an "away team" relationship. When you create a Game post, you will select one Home Team and one Away Team using these post relationships. You can do that in wp-admin in the Game post editor screen. If you plan to create Games using Forms, you'll need to create two Relationship Forms - one for creating a Home Team relationship and another for creating an Away Team relationship.
Next, you must create two Views of the Teams post type: one to show the Home Team information and another to show the Away Team information. Add a post relationship Query Filter. If you cannot see the Query Filter panel, scroll to the top right corner of the View editor screen and click "Screen Options" to turn on the Query Fiter panel. In the post relationship filter, choose the Home Team post relationship. Set it select items related to the post where this View is shown (see query-filter.png for an example using Books and Chapters instead of Teams and Games).
In the Loop Editor of this Home Team View, use custom fields to include the team logo and any other relevant Team information. Place this View in your Content Template for Games, where you want to display the Home Team information.
Once you have this View displaying correctly, you can duplicate it to create the Away Team View. Just modify the Query Filter in this new View to select the Away Team post relationship, and place this View in your Content Template for Games wherever you want to display the Away Team information.
This sounds like a great way to output the information, thank you for the explination, I'll give it a go and post back my results.
Thanks Christian.
Great, I'll stand by for your update.