Created
April 4, 2012 18:01
-
-
Save bueltge/2304293 to your computer and use it in GitHub Desktop.
Remove hierarchy on WordPress Category meta box
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_action( 'add_meta_boxes', 'do_my_meta_boxes' ); | |
function do_my_meta_boxes( $post_type ) { | |
remove_meta_box( 'my_taxonomydiv', $post_type, 'side' ); | |
add_meta_box( 'my_taxonomydiv', 'My Taxonomy', 'my_meta_box', $post_type, 'side' ); | |
} | |
function my_meta_box( $post, $meta_box ) { | |
$taxonomy = 'my_taxonomy'; | |
$tax = get_taxonomy( $taxonomy ); | |
$selected = wp_get_object_terms( $post->ID, $taxonomy, array( 'fields' => 'ids' ) ); | |
?> | |
<div id="taxonomy-<?php echo $taxonomy; ?>" class="categorydiv"> | |
<input type="hidden" name="tax_input[<?php echo $taxonomy; ?>][]" value="0" /> | |
<ul id="<?php echo $taxonomy; ?>checklist" class="list:<?php echo $taxonomy; ?> categorychecklist form-no-clear"> | |
<?php | |
wp_terms_checklist( $post->ID, array( | |
'taxonomy' => $taxonomy, | |
'selected_cats' => $selected | |
) ); | |
?> | |
</ul> | |
</div> | |
<?php | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment