I have a few custom taxonomies that I want to be shown as textboxes and in order to do that, the simplest way is in the custom taxonomy, you set them up as hierachical true. This makes them behave like categories. The problem is I really don’t want these things to be hierarchical. That is, I don’t want people adding in a parent/child relationship.

The simplest way around this is to cheat with CSS:

select#newtropes_parent {
    display: none;
}
.form-field.term-parent-wrap {
    display: none;
}

That hides the parent value. In order to have it show on the proper pages, I put it in a file called shows.css, in the same folder as my shows.php file that controls all the settings for the shows CPT (this includes the custom taxonomies used by shows) and wrapped it in this:

add_action( 'admin_enqueue_scripts', 'shows_my_scripts', 10 );
function shows_my_scripts( $hook ) {
	global $current_screen;
	wp_register_style( 'shows-styles', plugins_url('shows.css', __FILE__ ) );
	if( 'post_type_shows' == $current_screen->post_type || 'tropes' == $current_screen->taxonomy ) {
		wp_enqueue_style( 'shows-styles' );
	}
}

Now you can’t see that there are parents. Perfect. Done.

Reader Interactions

%d bloggers like this: