WordPress category tree-view

By default WordPress show flat list of categories if user selected some of them.

The code fixes it and shows tree-like list of categories in the admin section.

function category_tree_view( $args, $post_id ) {
    if ( get_post_type( $post_id ) == 'post' && $args['taxonomy'] == 'category' ) {
        $args['checked_ontop'] = false;
    return $args;
add_filter( 'wp_terms_checklist_args', 'category_tree_view', 1, 2 );

Or you may install Taxonomy Checklist Tree plugin.

Leave a Reply

Your email address will not be published. Required fields are marked *