Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Wordpress: Get taxonomy terms as checkboxes with labels
function get_terms_chekboxes($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;
echo get_terms_chekboxes('country', $args = array('hide_empty'=>true));
Copy link

Warface commented Mar 26, 2014

Awesome script simple and working as it should

Copy link

awunsch commented Jul 12, 2017

Hi, thanks for the great script :) How can you save the selected categories?

Best regards

Copy link

maugelves commented Sep 7, 2017

Thanks for the script!

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