After days and days of frustration, I’m proudly answering my own question.
The original code was not displaying multiple checkboxes because I was using the conditional !strcmp( $term->slug, $selected[0]->slug )
to render my “checked” options. Somehow it only returned 1 “checked” value at best.
The correct conditional simply gets the value of the selected option, and then verifies whether or not it exists in the $meta
array in order to return a checked="checked"
value. Hence the code below:
foreach ( $terms as $term ) {
echo '<label for="'.$field['id'].'">'.$term->slug.'</label>';
if (!empty ($selected) && in_array($term->slug, $meta))
echo '<input type="checkbox" name="'.$field['id'].'[]" value="'.$term->slug.'" checked="checked"/><br />';
else echo '<input type="checkbox" name="'.$field['id'].'[]" value="'.$term->slug.'"/><br />';
}