1

If I create a regular taxonomy for my custom post type, it behaves and looks like built-in tags taxonomy:

regular taxonomy appearance

And if I need to make it look like categories, I can add next 'hierarchical' => true parameter to a register_taxonomy call and it works well except if I don't need hierarchical features.

wp categories view

How to make custom post taxonomy looks like category, but disable hierarchical option?

2
  • Using WordPress built-in functions you can not achieve this. One way you could do it is performing some CSS coding just within this page. If it fits you just say the word and I can post you the solution. Feb 25 '17 at 15:49
  • @filipecsweb, you meant to simply hide "parent category" selector? but there are some such fields under "add new category" page. If you can cover them all - would be great :) Feb 25 '17 at 15:50
0

Within your functions.php:


function custom_admin_scripts( $hook ) {

    if ( $hook == 'post.php' && get_post_type() == 'your_custom_post_type_key' ) {
        wp_enqueue_style( 'your_custom_post_type_key', get_stylesheet_directory_uri() . '/my_css_file.css', array(), false, 'all' );
    }

}

add_action( 'admin_enqueue_scripts', 'custom_admin_scripts' );

Change your_custom_post_type_key to your custom post type key Change /my_css_file.css to your real path towards your css file.

Within your css file:


#{your_custom_taxonomy_key}-adder {
    display: none !important;
}

Change {your_custom_taxonomy_key} to your custom taxonomy key.

That CSS selector will hide, as aksed, the whole adder section.

This should do it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.