September 19, 2018
This makes working with filters so much easier. Many thanks to the original poster.
Functions.php:
function get_terms_checkboxes($taxonomies, $args) { $terms = get_terms($taxonomies, $args); foreach($terms as $term){ $output .= '<label for="'.$term->slug.'"><input type="checkbox" id="'.$term->slug.'" name="'.$term->taxonomy.'" value="'.$term->slug.'"> '.$term->name.'</label>'; } return $output; }
Place within template:
<?php echo get_terms_chekboxes('taxonomy', $args = array('hide_empty'=>true)); ?>
Sourced here.