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 have a taxonomy of menus i.e. Coffee, Tea, Sandwiches, Cakes etc. I want to add more information 'about' the taxonomy such as an image that represents it alongside the other pieces of taxonomy information (slug,name,description).

Is this possible, how would you go about it?

Thanks, Stewart

share|improve this question
2  
Bainternet and rilwis - both of your scripts not working well with multilanguage plugin WPML. –  jam Mar 28 '12 at 9:07
add comment

4 Answers

Currently only way to store additional metadata for taxonomies is, adding them to WordPress options (wp_options table). Just for an images, you can remove kses filter from term's description and insert image there.

// Remove kses filter from term descriptions
remove_filter( 'pre_term_description', 'wp_filter_kses' );

About storing taxonomy metadata in options tables, you can see Brad Williams post: http://www.strangework.com/2010/07/01/how-to-save-taxonomy-meta-data-as-an-options-array-in-wordpress/

share|improve this answer
add comment

As Mamaduka said there is currently no (native) way of storing meta-data for taxonmies. There is talk of it. But it has stalled since its proving difficult to agree on how best to implement it.

For large amounts of data you might not want to use the options table. Alternatively you can create your own taxonomy meta table. There are a couple plug-ins that currently do this:

  1. http://wordpress.org/extend/plugins/taxonomy-metadata/

  2. http://wordpress.org/extend/plugins/meta-for-taxonomies/

share|improve this answer
1  
+1 for Taxonomy Metadata plugin suggestion, that's good thing. –  Mamaduka Mar 23 '12 at 11:18
add comment

I coded a class that stores metadata for taxonomy terms in the options table and working with it is fairly simple ex:

//include the main class file
require_once("Tax-meta-class/Tax-meta-class.php");
// configure taxonomy custom fields
$config = array(
   'id' => 'demo_tax_meta_box',                     // meta box id, unique per meta box
   'title' => 'Demo Meta Box',                      // meta box title
   'pages' => array('menus'),                       // taxonomy name, accept categories, post_tag and custom taxonomies
   'context' => 'normal',                           // where the meta box appear: normal (default), advanced, side; optional
   'fields' => array(),                             // list of meta fields (can be added by field arrays)
   'local_images' => false,                         // Use local or hosted images (meta box images for add/remove)
   'use_with_theme' => false                        //change path if used with theme set to true, false for a plugin or anything else for a custom path(default false).
);

// Initiate your taxonomy custom fields
$my_meta = new Tax_Meta_Class($config);

// Add fields

//text field
$my_meta->addText('text_field_id',array('name'=> 'My tax Text '));
//textarea field
$my_meta->addTextarea('textarea_field_id',array('name'=> 'My tax Textarea '));
//Image field
$my_meta->addImage('image_field_id',array('name'=> 'My tax Image '));
//Finish Taxonomy Extra fields Deceleration
$my_meta->Finish();

this will add a text field, textarea field and an image field. And getting the stored data is also very simple:

$saved_data = get_tax_meta($term_id,'text_field_id');
echo $saved_data;

currently the class supports:

  • Input
  • Textarea
  • Radio button
  • Checkbox
  • Select Dropdown
  • File Upload
  • Image Upload
  • WYSIWYG editor
  • Date Picker
  • Time Picker
  • Color Picker
  • Taxonomy List Dropdwon
  • Post list Dropdown
  • Repeater Field

to read more about it look at : WordPress taxonomies extra fields the easy way

share|improve this answer
add comment

I wrote a Taxonomy Meta Script for WordPress, which can help you easily implement taxonomy meta.

share|improve this answer
add comment

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.