I need a pointer on how to get the data from the multicheck
I am guessing I need to use a foreach but if I do var_dump($array) I get
array(1) { [0]=> string(1) "3" }
Which doesn't tell me what I need to pull out of the array in the foreach, can anyone spread any light on the best way of doing this?
Data from a multicheck (or select, group, etc) is stored as a serialized array in the meta value. So, to use it you need to put it in a foreach and use the data. Something like this:
$array= get_post_meta( $post_id, 'prefix_meta_key', true );
if( $array ) {
foreach( $array as $key => $value ) {
echo 'This is the value: ' . $value . ' for this key: ' . $key; // or whatever else you want to do with the data
}
}
Cheers Josh
Unfortunately your code didn't work Josh but trial and lots of searching did, and used:
get_the_term_list( $post->ID, 'taxonomy', '', ', ' );
@gareth-gillman I think you neglected to mention you were trying to get the data from a taxonomy_multicheck which is definitely different than getting data from a standard multicheck.
This one should help https://github.com/WebDevStudios/CMB2/issues/212 but get_posts what do You want.
Matt
Thank you @joshuadavidnelson! Your response helped me out with my own project.