wp_category_checklist

Output an unordered list of checkbox input elements labeled with category names.

Description

wp_category_checklist( (int) $post_id = 0, (int) $descendants_and_self = 0, (constant) $selected_cats = false, (constant) $popular_cats = false, (constant) $walker = null, (bool) $checked_ontop = true ); 

Parameters (6)

0. $post_id — Optional. (int)
Post to generate a categories checklist for. Default 0. $selected_cats must not be an array. Default 0.
1. $descendants_and_self — Optional. (int)
ID of the category to output along with its descendants. Default 0.
2. $selected_cats — Optional. (constant) => false
List of categories to mark as checked. Default false.
3. $popular_cats — Optional. (constant) => false
List of categories to receive the popular-category class. Default false.
4. $walker — Optional. (constant) => null
Walker object to use to build the output. Default is a Walker_Category_Checklist instance.
5. $checked_ontop — Optional. (bool) => true
Whether to move checked items out of the hierarchy and to the top of the list. Default true.

Usage

  1. if ( !function_exists( 'wp_category_checklist' ) ) { 
  2. require_once ABSPATH . '/wp-admin/includes/template.php'; 
  3.  
  4. // Optional. Post to generate a categories checklist for. Default 0. 
  5. // $selected_cats must not be an array. Default 0. 
  6. $post_id = -1; 
  7.  
  8. // Optional. ID of the category to output along with its descendants. 
  9. // Default 0. 
  10. $descendants_and_self = -1; 
  11.  
  12. // Optional. List of categories to mark as checked. Default false. 
  13. $selected_cats = false; 
  14.  
  15. // Optional. List of categories to receive the "popular-category" class. 
  16. // Default false. 
  17. $popular_cats = false; 
  18.  
  19. // Optional. Walker object to use to build the output. 
  20. // Default is a Walker_Category_Checklist instance. 
  21. $walker = null; 
  22.  
  23. // Optional. Whether to move checked items out of the hierarchy and to 
  24. // the top of the list. Default true. 
  25. $checked_ontop = true; 
  26.  
  27. // NOTICE! Understand what this does before running. 
  28. $result = wp_category_checklist($post_id, $descendants_and_self, $selected_cats, $popular_cats, $walker, $checked_ontop); 
  29.  

Defined (1)

The function is defined in the following location(s).

/wp-admin/includes/template.php  
  1. function wp_category_checklist( $post_id = 0, $descendants_and_self = 0, $selected_cats = false, $popular_cats = false, $walker = null, $checked_ontop = true ) { 
  2. wp_terms_checklist( $post_id, array( 
  3. 'taxonomy' => 'category',  
  4. 'descendants_and_self' => $descendants_and_self,  
  5. 'selected_cats' => $selected_cats,  
  6. 'popular_cats' => $popular_cats,  
  7. walker => $walker,  
  8. 'checked_ontop' => $checked_ontop 
  9. ) );