1
votes

For a new project i like to have a single of my custom post type 'teams' as a parent of a custom post type archive and singles 'report' so i would like to have "Teams/{team-name}/reports/{report}".

I've tried to create a custom slug with the 'save_post' action/hook but it didn't work. On the editor page of a report i do have a custom field to select a team but ik look likes this is not usable on the save_post function yet. Does anyone have a suggestion?

1
What's your end goal of this? ie, what is it you want to see when you visit what page? - Madivad
are the reports generated under each team different? Is a CPT the best way to achieve segregation of your report data? What I mean by that, is it possible to do away with the Team CPT and assign a custom taxonomy to the reports associated with each team? Or you could create that taxonomy common to both the Teams and Reports CPT and link them that way. Then generate the page flow yourself via custom single and archive combined based on the category/taxonomy - Madivad
It's a website for a sport club. You should be able to visit a team (detail) and should also be able to read a report about a game of that team. i'd like to have a nice url for that report page. - Jack van der Klooster
I've used CPT because coaches of a team can write but can't publish game reports - Jack van der Klooster

1 Answers

0
votes

Based on what you've indicated in the comments above, I'd be inclined to do away with the http://{website}/Teams/{team-name}/reports/{report} pretty URL and have a more simple http://{website}/Teams/{team-name} URL. It will be more intuitive to remember for visitors.

In the single for the Team CPT, you would include a loop for the archive type associated with the particular team. You COULD create a hierarchy of CPT where Reports are a child of Team but you will be heading down a slippery road that the parent/child relationship creates a lot of overhang when the types become populated.

There are a lot of threads about this, this is just one guys report on what happens when there are many hierarchical CPTs: https://wordpress.org/support/topic/hierarchical-post-type-w-heavy-data-set-fails-lots-of-custom-fields?replies=1

If you could create them as individual (non related) CPTs, and have a common category or taxonomy you could then in the single.php of your CPT include a loop for the archive, or alternatively in the archive for the reports, you could include a team header section. You could link the two on that taxonomy.

On a slightly different tact, if it is just some basic info you want to have about the team on the archive page, you could include a description in the reports taxonomy and depending on your theme (or custom coding) you could display that at the top of the reports archive.