Skip to content

Instantly share code, notes, and snippets.

@jbreitenbucher
Created December 31, 2011 05:36
Show Gist options
  • Save jbreitenbucher/1543014 to your computer and use it in GitHub Desktop.
Save jbreitenbucher/1543014 to your computer and use it in GitHub Desktop.
Code to return data from multicheck taxonomy field
$styles = get_post_meta($post->ID, 'it_classroom_style_taxonomy',true) ;
echo $styles[0];
$style = get_term_by( 'id', $styles[0], 'style' );//get_term($styles[0], 'style');
print_r($style);
echo $style->name;
@jbreitenbucher
Copy link
Author

This taxonomy returns the correct name
register_taxonomy(
'building',
'itclassroom',
array(
'hierarchical' => false,
'labels' => $labels_building,
'query_var' => true,
'rewrite' => array( 'slug' => 'buildings', 'with_front' => false ),
)
);
and this one is not
register_taxonomy(
'style',
'itclassroom',
array(
'hierarchical' => false,
'labels' => $labels_classroom,
'query_var' => true,
'rewrite' => array( 'slug' => 'classroom-styles', 'with_front' => false ),
)
);
The metaboxes are generated with
array(
'name' => 'Building',
'desc' => '',
'id' => $prefix . 'building_taxonomy',
'taxonomy' => 'building', //Enter Taxonomy Slug
'type' => 'taxonomy_radio',
),
and
array(
'name' => 'Classroom Style',
'desc' => '',
'id' => $prefix . 'classroom_style_taxonomy',
'taxonomy' => 'style', //Enter Taxonomy Slug
'type' => 'taxonomy_multicheck',
),

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment