Make WordPress Core

Opened 5 years ago

Closed 5 years ago

#25082 closed defect (bug) (wontfix)

register_taxonomy_for_object_type cannot be used with non-post types

Reported by: leewillis77 Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.0
Component: Taxonomy Keywords: has-patch
Focuses: Cc:


register_taxonomy_for_object_type checks that the object type is a post_type object, and will not let you register the taxonomy for the object type if it is not:


During discussion with nacin on IRC relating to #11058 he suggesting removing the get_post_type_object check from the new unregister_taxonomy_from_object_type function since it didn't seem to be sensible.

This ticket is open to investigate the restriction in register_taxonomy_for_object_type and see if it can also be removed.

Patch attached in case the collective wisdom decides that it is unnecessary.

Attachments (1)

25082.diff (475 bytes) - added by leewillis77 5 years ago.
Proposed patch

Download all attachments as: .zip

Change History (4)

5 years ago

Proposed patch

#1 @SergeyBiryukov
5 years ago

  • Version changed from 3.6 to 3.0

Introduced in [12597] along with the function itself.

#2 @ryan
5 years ago

Which object types do we have in mind? Seems we'd have to make sure that the taxonomy isn't registered for multiple object types that aren't all of the same class ( post | user | whatever ).

#3 @nacin
5 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to wontfix
  • Status changed from new to closed

On further thought, this function should be limited to post types. I was wrong earlier.

Registering a taxonomy for an object type that isn't a post type is a fairly dangerous affair. If a single taxonomy handles both a post type and a non-post type, you end up with ID conflicts. I'm not sure I can think of a situation where it should be allowed. Removing this check therefore probably isn't prudent — actual assignment of a non-post object type should occur only on registration of the taxonomy.


Note: See TracTickets for help on using tickets.