[wp-hackers] Category/Tag/Taxonomy Meta Data

The WordPress Web Warlock wordpress at web-warlocks.net
Mon May 31 22:35:52 UTC 2010

En/na Nathan Rice ha escrit:
> I notice that there is an action hook that allows you to add extra form
> fields to the Edit Category/Tag/Tax page, {taxonomy}_edit_form_fields, which
> is VERY cool. But this action hook seems pretty useless unless the new form
> field you insert actually allows you to save some extra data.
> For instance, let's say that I wanted to add another textarea that allowed a
> user to insert a "short" description of the category to be used somewhere in
> the theme. I can figure out how to insert the form field, but I can't figure
> out why the data won't actually save. I imagine there's some sort of
> sanitization going on that limits what can and can't be saved, but is there
> any way to bypass that?
Well, there are two sets of actions here. On the one side, there are 
hooks to *display* the fields (like edit_category_form and edit_tag_form 
in 2.9.x and earlier; I understand that the {taxonomy}... are new to 3.0? ).
To *save* them, you must add another action to edited_category or 
edited_term hooks, and use the vars passed via $_POST (I don't remember 
right now if they can take additional args, that'd be worth a look).
Quite like meta boxes, indeed...
(At least, that's how I do it in 2.9, and works fine & nice. Dunno if 
the procedure is supposed to change in 3.0.)

> Bottom line ... is there any way to add extra fields of data, without
> resorting to storing this data in the options table? We have this sort of
> thing in place for posts (postmeta), comments (commentmeta), and users
> (usermeta), but it would be cool if it could be done with taxonomies too.

AFAIK, the only suitable place in a out-of-the-box WP installation is 
the options table. But a table (termmeta) can be added; there're some 
plugins which do that, there's dbDelta...
I'd say that the taxonomymeta which Glenn Ansley mentions, and 
wp_object_relationships_meta would be really sweet tables too :)

More information about the wp-hackers mailing list