Skip to content
bainternet edited this page Jun 15, 2012 · 8 revisions

#Input Field

To add a Taxonomy field to your metabox simply use the addTaxonomy method of the metabox object:

$my_meta =  new AT_Meta_Box($config);
$my_meta->addTaxonomy('taxonomy_field_id',array('taxonomy' => 'category'),array('name'=> 'My Taxonomy '));

Method arguments:

  • ID: field id (string)
  • options: (mixed|array)
    •  '_taxonomy_' =>  taxonomy name can be category,post_tag or any custom taxonomy default is category (string) optional
      
    •  '_type_' =>  how to show taxonomy? 'select' (default) or 'checkbox_list', (string) optional
      
    •  '_args_' =>  arguments to query taxonomy, see http://goo.gl/uAANN default ('hide_empty' => false)  (array) optional
      
  • args: (mixed|array)
    •  '_name_' =>  field name/label, (string) optional
      
    •  '_desc_' =>  field description, (string) optional
      
    •  '_std_' =>   default value, (string) optional
      
    •  '_style_' => custom style for field, (string) optional
      
    •  '_validate_func_' => validate function name, (string) optional
      
  • reapeater: When adding this field to a repeater block set to true (default false)

Get Field Data:

The Taxonomy field stored the selected term id in the database so to echo out the term id use:

$saved_data = get_post_meta($post->ID,'taxonomy_field_id',true);
echo $saved_data;
Clone this wiki locally