I have a custom post type called “Professions”, it contains different professions and info about them. To show them I simply use a content-profession.php
-file.
The thing is that I need subpages (childs) to those professions that contains info like salary, terms, where to find jobs, etc. They cannot be of the same type as the CPT Professions since that post type have a very specific layout. Is there any way to get a normal page as a child of a custom post type?
This was previously discussed here:
Page as child in custom post type slug?
but with the solution of rewriting URLs which feels like a very “hacky” solution to the problem.
When you register the post type you can set hierarchical to true.
Then make sure the supports array includes page-attributes to show the parent menu.
eg:
More info in the codex
The plugin mentioned by Barry seem pretty much what you need, but if you don’t want to buy anything, here’s another possible solution:
You could add a custom field in the subpages themselves holding the profession id.
Then in the profession page, you could do a post query with as argument the meta value to get all the pages that have this profession id as a custom field value. And like this generate your links…
The good think is that if you decide that some of these pages are repeated for every profession and have always same layout, you could turn them into there own custom post type, you would just need to include them in the query, but all the rest can work with the same logic…