我禁用了父框,以避免父框向左移动。
add_action( \'admin_footer-post.php\', \'wpse_98274_disable_top_categories_checkboxes\' );
add_action( \'admin_footer-post-new.php\', \'wpse_98274_disable_top_categories_checkboxes\' );
/**
* Disable parent checkboxes in Post Editor.
*/
function wpse_98274_disable_top_categories_checkboxes() {
global $post_type;
if ( \'post\' != $post_type )
return;
?>
<script type="text/javascript">
jQuery( "#category-all ul.children" ).each( function() {
jQuery(this).closest( "ul" ).parent().children().children( "input" ).attr( \'disabled\', \'disabled\' )
});
</script>
<?php
}
然而,一旦类别因可怕的“特性”而无序移动到框的顶部,jQuery就会失败。我从
a plugin.
add_filter( \'wp_terms_checklist_args\', \'wpse_98274_checklist_args\' );
/**
* Remove horrid feature that places checked categories on top.
*/
function wpse_98274_checklist_args( $args ) {
$args[\'checked_ontop\'] = false;
return $args;
}