Last active
November 25, 2018 19:04
-
-
Save lunaroja/5843383 to your computer and use it in GitHub Desktop.
Wordpress: Get taxonomy terms as checkboxes with labels
This file contains hidden or 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
<?php | |
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)); |
Hi, thanks for the great script :) How can you save the selected categories?
Best regards
André
Thanks for the script!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Awesome script simple and working as it should