Make your clients’ lives easier by allowing them to add/remove all the terms in a custom taxonomy from a post with a single click.
Simply add the following script to your functions.php file (make sure to update the checklist selector to match the appropriate id for your site):
/* Add Select All Checkbox to Custom Taxonomy */
add_action( 'admin_print_footer_scripts', 'my_custom_taxonomy_check_all' );
function my_custom_taxonomy_check_all() {
?>
<script type="text/javascript">
jQuery(document).ready(function($) {
$('ul#mytaxonomychecklist').prepend('<li><label class="selectit"><input type="checkbox" class="toggle-all-terms"/> Check All Terms</label>');
$('.toggle-all-terms').on('change', function(){
$(this).closest('ul').find(':checkbox').prop('checked', this.checked );
});
});
</script>
<?php
}That’s it! Have any questions? Leave a note below in the comments!