How to remove child selection when adding or editing taxonomies for custom post type

21 May 2014August InfotechOthers

add_action( 'admin_head-edit-tags.php', 'remove_child_taxonomy_selection_box' );

function remove_child_taxonomy_selection_box()
{
// don't run in the Tags screen
if ( 'customposttype_name' != $_GET['taxonomy'] )
return;

// Screenshot_1 = New Category
// http://example.com/wp-admin/edit-tags.php?taxonomy=category
$parent = 'parent()';

// Screenshot_2 = Edit Category
// http://example.com/wp-admin/edit-tags.php?action=edit&taxonomy=category&tag_ID=17&post_type=post
if ( isset( $_GET['action'] ) )
$parent = 'parent().parent()';
?>

jQuery(document).ready(function($)
{
checkval();
$("#parent").live('click',function(){
checkval();
});
});
function checkval()
{
jQuery("#parent option").each(function(index){
if(!jQuery(this).hasClass('level-0'))
{
jQuery(this).remove();
}
});
}

<?php
}



Free Quote & Consultation