在小部件中使用wp_category_checklist
我正在尝试在小部件中使用wp_category_checklist来显示复选框列表,这些复选框在保存时仍保持勾选状态。据我所知,目前保存它们时,我遇到了很大的麻烦(未选中复选框):- 这是我目前拥有的已编辑代码。 function update($new_instance, $old_instance) { $instance = $old_instance; $instance['widget_categories'] = $new_instance['post_category']; return $instance; } function form($instance) { $instance = wp_parse_args( (array) $instance, $default ); $categories = get_categories(); $category_array = $instance['widget_categories']; if (!$category_array) { $category_array = array(); } ?> <ul class="categorychecklist"> <?php wp_category_checklist(0,0, $category_array,false, NULL , false);?> </ul> <?php } …