[wp-hackers] Using Taxonomy for Users, Comments, Post Meta, etc?

Otto otto at ottodestruct.com
Tue Dec 28 15:53:34 UTC 2010

Taxonomy is generic. It can apply to anything.

Specifically, you can use wp_set_object_terms to assign an integer
(the object ID) to have a term in a given taxonomy. Similarly, you can
use wp_get_object_terms to get the data back, and so forth. However,
all you're really doing is to give an ID number a relationship to a
term (in a taxonomy). How you interpret that relationship is up to
you. If you want to use user_id's, then by all means, go for it. I've
used it for exactly that.

That said, taxonomies are mostly geared towards posts, in the sense
that a lot of the post query code lets you select based on
relationships between post ID's and terms. That's the main use case.
If you want to, say, select comments with a given term on them, then
you're probably going to be rolling your own SQL for now to select
those comments.

At wp.org, we use taxonomies to assign users certain terms for the
purpose of the email subscriptions. When you subscribe to a thread, a
term created for that thread in a special taxonomy get a relationship
to the user ID. When it comes time to send an email, a query is done
to get all the users associated with that term. Similar behavior is
used for the "tag" subscriptions.


On Tue, Dec 28, 2010 at 8:50 AM, Mike Schinkel
<mikeschinkel at newclarity.net> wrote:
> Hi all,
> I'm having a discussion over WordPress Answers in the comments for this question[1] about the use of the taxonomy system for classifying items other than posts such as users, comments, postmeta, etc. I had been thinking it was a foregone conclusion that the taxonomy system was designed to be used with more than just posts but the fact that someone is making some good points to question that logic is making me question it too.
> OTOH one of his arguments I still don't agree with is "If there are no functions to support the use of taxonomy for items other than posts then it's better to create new tables."
> Can anyone speak to if 1.) the taxonomy system was actually designed with more than posts in mind,  2.) if anyone is using the taxonomy system successfully to classify items other than posts, and 3.) if anyone can comment on if adding new tables vs. reusing the existing taxonomy tables is more appropriate and why?
> Thanks in advance.
> -Mike
> [1] http://wordpress.stackexchange.com/questions/5974/creating-a-custom-admin-panel
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers

More information about the wp-hackers mailing list