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!

Allen Robinson

Director of Application Development
Allen has been responsible for overseeing client website development, implementation, and maintenance at Foxtrot Media for over 10 years. A Computer Science graduate from the University of Wisconsin- Madison, Robinson is a software development and content management system specialist, fluent in CSS, PHP, MySQL, HTML, and JavaScript.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Allen Robinson

Director of Application Development
Allen has been responsible for overseeing client website development, implementation, and maintenance at Foxtrot Media for over 10 years. A Computer Science graduate from the University of Wisconsin- Madison, Robinson is a software development and content management system specialist, fluent in CSS, PHP, MySQL, HTML, and JavaScript.

Post Details

Categories:

Languages:

Related Resources: