Can a Child Category Have More than One Parent?

No, a term can have many children, but only a single parent. The parent field in the database can hold only a single value.

It is a hierarchical one to many relationship, not a many to many relationship.

The same is true of posts. A post can have only 1 parent, but many children. To get around that you would use taxonomies.

A sidenote on wp_term_taxonomy, and Hard Proof

It’s been suggested that the same term could have multiple entries in this table allowing it to have multiple parents and be shared across multiple parent terms.

Here is the database schema:

enter image description here

As you can see if the same term and taxonomy were referred to multiple times, but with a different parent, perhaps a term can have multiple parents?

No, the term_id and taxonomy_id are both unique, such a thing would not be possible to create in that table without changing its schema. To demonstrate this, I opened up sequel pro.

Here we have a term in my local copy of my blog:

enter image description here

It has a parent of 4, lets attempt to give it a second parent of 5:

INSERT INTO `tjn2_term_taxonomy` (`term_taxonomy_id`, `term_id`, `taxonomy`, `description`, `parent`, `count`)
VALUES
    (13, 13, 'category', '', 5, 0);

When ran this query gives the following error:

enter image description here

So no, a term cannot have more than one parent. But even if it could, there would be no mechanism in the APIs to find out short of raw SQL statements, so such a term would be useless and unusable in the frontend and backend UIs

Leave a Comment