-
-
Save billerickson/1547439 to your computer and use it in GitHub Desktop.
Code to return data from multicheck taxonomy field
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$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; |
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
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?