Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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?

share|improve this question

3 Answers 3

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

share|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
sagive

share|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
up vote -1 down vote accepted
update_metadata()

great post on Adding Custom Fields to Taxonomy.

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

share|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. –  Christopher Ickes 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

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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