Let’s say you have a custom post type for football players called /footballers/ that has a repeater field that shows which teams they’ve played for and for what years.
So, for example, these are two separate posts each with a repeater field with sub fields for: from / to / team:
Mr Footballer
2010 2015 Arsenal
2001 2010 Liverpool
1999 2001 Spurs
Master Goalie
2010 2015 Man United
2001 2010 Arsenal
1999 2001 Chelsea
Is it possible to then query the repeater field for all posts within the /footballer/ post type to show which players played for a specific team.
Eg:
Arsenal
Mr Footballer 2010 2015
Master Goalie 2001 2010
Ok thanks. So that would allow you to identify which posts had relevant values for the repeater field, and I’m guessing you’d then have to further filter by the sub fields to only output the rows you’re interested in?
So to use my example we’re finding the posts that contain references to “Arsenal” in the team_% sub field, and then from those posts we need to output the values from only the rows that contain the team “Arsenal”.
Is it possible to somehow sort the information by a value in the sub field? Eg: So that the relevant rows from the sub fields are sorted by the relevant startyear field for that row?
I know it my be a headache, but would you not be better off having a custom post type of footballers and then using custom taxonomy of say teams.
But the team is then listed team name and year? As you can’t do teams and years individually as you don’t know what year they played for said team
May be easier to query!
Ok thanks – I thought that was the case as that’s similar to how we’ve been doing it, but wanted to double check there wasn’t a better way.