Skip to content

Instantly share code, notes, and snippets.

@bueltge
Created April 4, 2012 18:01
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bueltge/2304293 to your computer and use it in GitHub Desktop.
Save bueltge/2304293 to your computer and use it in GitHub Desktop.
Remove hierarchy on WordPress Category meta box
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