Skip to content

Instantly share code, notes, and snippets.

@billerickson
Forked from jbreitenbucher/classroomstyle
Created January 1, 2012 14:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save billerickson/1547439 to your computer and use it in GitHub Desktop.
Save billerickson/1547439 to your computer and use it in GitHub Desktop.
Code to return data from multicheck taxonomy field
$styles = maybe_unserialize( 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

Thanks Bill. It seems that get_the_term_list($post->ID, 'style', 'Classroom Style: ', ', ', '
'); works and is much easier than all the above. So I'm not sure why there was a need to code things as above. Maybe get_the_term_list() was not around at the time?

@billerickson
Copy link
Author

Yes, get_the_term_list() is a better solution but it doesn't use the data in post meta. When you're using one of the taxonomy fields (taxonomy_select, taxonomy_radio...), it stores this data as postmeta AND sets that post's taxonomy to those terms.

Using the method you describe, you're simply using the metabox as the backend editor for selecting taxonomy terms. You're not actually using any of the data it stores.

The way you describe is the way I'd prefer doing it.

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