Set relationship between custom_post_types

I would suggest you create a common hierarchical taxonomy that you register with each of your custom post types.

The terms of this taxonomy would match your custom post types (for example use the custom post type slug as the term slug).

You can then structure your taxonomy to match your designed hierarchy, and every time you need to find the parent/child you refer back to the taxonomy.

You could have a parent_post and a child_post meta fields to store the post IDs of the respective parent and child post.

Leave a Comment