You can add taxonomy metadata, similar to add_post_meta
and some examples of doing so include,
Tutorial Walk-Through
Taxonomy Metadata Class (improved version of above)
I have personally used this class myself which was also authored from a reputable member and moderator here at WPSE -> Bainternet
, it did what it said on the box.
Plugin
Tutorial Walk-Through
- http://www.wphub.com/adding-metadata-taxonomy-terms/
- Simple Term Meta Plugin (Plugin mentioned in tutorial walk-through)
That aside…
If you have a user, named Jack for instance, then why don’t you assign the user to the custom post type via a post meta field in a meta box?
So you’d be looking at,
You can still use custom taxonomies to help you further classify or group your data, but a lot of what you are trying to achieve is quite simply the same as if you were doing it with posta meta data to begin with (i.e. add_post_meta)
And to simplify things, you can you a meta box class to roll out your solutions,
http://en.bainternet.info/2012/how-i-add-a-wordpress-metabox
http://www.deluxeblogtips.com/meta-box/
http://www.farinspace.com/wpalchemy-metabox/
I have used all of the above, each of which are good. I still use WPAlchemy and the Meta-Box class from Deluxe Blog Tips. As for Bainternet’s, there’s nothing wrong with that class, its a matter of using too many already. So take your pick.
UPDATE
My approach to this would be to,
- a) create a custom post type Birds
- b) create a taxonomy Bird Type
-
c) create a meta box with two fields
- 1) lists users in a drop down
- 2) name of users bird
The process would be to,
- a) add a Bird, such as Canary
- b) add a taxonomy term that matches the name of the bird, e.g. Canary
- c) add a user in my meta box associated with this bird
- d) if available at the time of creation, add the given name the user chooses for the bird
Using a repeatable field that has an Add Now button, you can add another user. But instead of grouping all of the meta fields into one post meta_key
, you need to create separate post meta keys for each user you wish to associate with the bird, otherwise you’ll end up with serialized data which is slow to query.
Even this approach can be improved.
You could instead associate the Taxonomy “Canary” to the user via User Meta instead.
For each type of bird in the users collection, you would use add_user_meta to apply a name the user chooses for the bird.
Your meta box that you create via add_meta_box
isn’t strictly limited to using add_post_meta
etc functions, you could write your function to use add_user_meta
and update_user_meta
instead. So on and so on.
This leaves clear separation between each of your elements.
- Custom Post Type is for the Bird which might explain the bird, its origin, etc
- Taxonomy is for the classification of the Bird
- Meta Box / User Meta function is to associate Taxonomy and given name of Bird to user
The post_parents
idea really isn’t a good one, I have to say, because creating a new Post for what is otherwise meta data in the first place equates to bloat when we already have the Taxonomy and User tables to go along with the Posts table for your custom post type.