I am trying to create a custom field for a custom taxonomy. update_post_meta works great with posts. Taxonomies are not posts so this won't work.

<?php update_post_meta($post_id, $meta_key, $meta_value, $prev_value); ?> 

How would I save a custom field within a custom taxonomy? Other solutions include the options_table (bad!) or creating a custom table (cumbersome). Is there another, canned solution or function to help with this?


Correct me if I'm wrong, but isn't what you're looking for the wp_set_object_terms function?

|improve this answer|||||
  • This doesn't answer the question. But +1, as it's often overseen. – kaiser Jul 24 '12 at 20:31

First you need to add the fields you wish to attach to that taxonomy...
There are several solution but a gr8 member of wordpress.stackexchange.com
called @bainternet released the best solution i have seen yet for:

  • adding fields to your taxonomies & Saving them.

You should have a look:
wordpress taxonomies extra fields the easy way

it helped solved a recent project.
hope this answers your need...

Best of luck

|improve this answer|||||
  • This solution saves every set of meta data as entry in the options table. Not a nice solution and will clutter a table, that holds most of the autoloaded options, so it will slow down every request over the time. – kaiser Jul 24 '12 at 20:31

great post on Adding Custom Fields to Taxonomy.

The solution outlined does require creating an additional database table but it does the job perfectly.

|improve this answer|||||
  • Adding another table to store meta data is not the best way - not recommended. – kaiser Jul 24 '12 at 20:29
  • Why? Is there a better solution? We are talking about saving metadata for custom fields on a custom post type. Couldn't find anything canned that fits. What is better? Still learning so thanks. – csi Jul 25 '12 at 18:12
  • n/p. You can use the description columns content inside the term_taxonomy table. There you simply save a JSON encoded array. – kaiser Jul 25 '12 at 19:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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