Is there a way to nest taxonomies or custom fields deeper than one level below the post type?

WordPress content is implemented in two foundational structures: Posts represent distinct “instances” of content, and Taxonomy Terms aggregate and organize Posts according to their shared qualities. Meanwhile “custom fields” – or more specifically Meta-data/”Meta” – can be used to add arbitrary data to both Posts and Terms (among other things).

Analogous to classical OOP, a Post Type would be similar to a sub-class for content, and individual Posts of that type it’s instances. Post meta-data operates similarly to class fields/properties in cases where WordPress’s parent Post class does not provide the necessary fields.

While there are many ways in which you could implement the proposed project, the more closely you can adhere to WordPress’s core ideology, the more you can take advantage of it’s built-in functionality such as automatic routing and archive pages/functions to display associated content.

I’d consider implementing the following:

  • Toy is a custom post type
  • Color is a custom (non-hierarchical) taxonomy applied to Toys. This way each Color term aggregates Toys with the same color
  • Person is a custom post type.
  • If pets are just general types of pets rather than specific pets (e.g. “Spike”), I’d make Pet another custom taxonomy, which could apply to both the Person and Toys post-types. This way Toys can can be aggregated based on applicable pets, and Persons can be aggregated based on the pets they own.

The only caveat here is if “people” are actual end-users of the site, in which case you might store the term slugs for owned types of pets in User meta instead of creating another post type (effectively creating a new relationship between a user and a Term which WordPress does not support out-of-the-box). This would mean that you’d need to implement a little more logic for Person-related queries in order to query Toys based on the Pet terms stored in a user’s meta, but ultimately it wouldn’t add too much complexity.

The above is probably the most direct solution, but you could certainly extend it in many ways, such as creating a Pet post-type as well in order to provide pet information content, also classifying the Pet post-type with the Pet taxonomy in order to facilitate simple query logic.

Finally, if you wanted to start adding hierarchies to the above, you could register the Pets taxonomy to be hierarchical such that say Skink is a child term of Reptile. Or register the Toy CPT as hierarchical in order to represent variations of a Toy or some such.

In short, I think WordPress supports the basic scenario presented fairly-well out of the box. But you can always craft custom relationships between objects. It’s all very flexible – you might simply need to put in some work on modifying URL rewrites, queries, and templates in order to represent it all as you intend.