好的,因为我没有任何回应SOLUTION 我的自我,以便对其他想要这样做的人有用:
add_filter(\'wp_terms_checklist_args\', \'display_custom_checklist\');
function display_custom_checklist( $args ){
if ( $args[\'taxonomy\'] == \'portfolio-type\' )
$args[\'walker\'] = new my_custom_walk;
return $args;
}
class my_custom_walk extends Walker {
var $tree_type = \'category\';
var $db_fields = array (\'parent\' => \'parent\', \'id\' => \'term_id\'); //TODO: decouple this
function start_lvl( &$output, $depth = 0, $args = array() ) {
$indent = str_repeat("\\t", $depth);
$output .= "$indent<ul class=\'children\'>\\n";
}
function end_lvl( &$output, $depth = 0, $args = array() ) {
$indent = str_repeat("\\t", $depth);
$output .= "$indent</ul>\\n";
}
function start_el( &$output, $category, $depth, $args, $id = 0 ) {
extract($args);
if ( empty($taxonomy) )
$taxonomy = \'category\';
if ( $taxonomy == \'category\' )
$name = \'post_category\';
else
$name = \'tax_input[\'.$taxonomy.\']\';
$class = in_array( $category->term_id, $popular_cats ) ? \' class="popular-category"\' : \'\';
$output .= "\\n<li id=\'{$taxonomy}-{$category->term_id}\'$class>" . \'<label class="selectit"><input value="\' . $category->term_id . \'" type="checkbox" name="\'.$name.\'[]" id="in-\'.$taxonomy.\'-\' . $category->term_id . \'"\' . checked( in_array( $category->term_id, $selected_cats ), true, false ) . disabled( empty( $args[\'disabled\'] ), false, false ) . \' /> \' . esc_html( apply_filters(\'the_category\', $category->name.\' - \'.$category->slug )) . \'</label>\';
}
function end_el( &$output, $category, $depth = 0, $args = array() ) {
$output .= "</li>\\n";
}
}