1

Starting with WP 2.3 we can do this:

register_taxonomy('custom_taxonomy', array('user', 'post', 'link', 'comment'));

Those are different object types that belong to different tables and hence can have same primary key ID. Now if we take a look at the functions used to get or check terms, they all lack object_type parameter.

is_object_in_term( $object_id, $taxonomy, $terms = null );
wp_get_object_terms( $object_ids, $taxonomies, $args );

As a matter of fact, there is no reference to object type in term_relationships table at all, and you are going to get false positives for objects with same IDs. How can one fix that?

1 Answer 1

1

Those are different object types that belong to different tables and hence can have same primary key ID.

--> Even though these are different types, all are being stored in one table i.e. wp_posts with post_type = the different types. Check the table structure for clarity. So there won't be any same ID conflict.

if we take a look at the functions used to get or check terms, they all lack object_type parameter.

--> This is not needed. When we have the object itself, WordPress functions can better decide its associated type from the DB.

As a matter of fact, there is no reference to object type in term_relationships table at all, and you are going to get false positives for objects with same IDs.

--> This is also wrong assumption. There is clear relationship between the tables need to manage the categorizations in WordPress. Here is a snap that explains relationships. enter image description here

3

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.