I have a custom hierarchical taxonomy that is called ‘Categories’, but serves a different area of the site than the default “Categories” taxonomy. The problem I’m having is with selecting children terms in the interface while posting content. If the user selects and children terms, they move to the top of the Categories box and lose association and visual hierarchy with its parent. Here’s an image showing what happens:

Checked categories are moved to the top of the list, breaking the hierarchy

I haven’t set any unusual parameters that I know of, here’s the register_taxonomy call:

register_taxonomy( "workshop_categories", 'workshop',
    array(
        "label" => "Categories",
        "singular_label" => "Category",
        "rewrite" => true,
        "show_ui" => "true",
        'hierarchical' => true,
        'rewrite' => array('slug' => 'category')
    )
);

Any input is appreciated!

4 Answers
4

This seems to be normal, it also happens for categories. The wp_terms_checklist(), which creates the checklist, has an argument checked_ontop, enabled by default. The metabox does not override this, so checked categories or custom terms always appear on top of the list. This does not affect their actual hierarchy, only how they are displayed there. It seems the remaining items of the hierarchy, that “lost” their parent, are added to the bottom.

I do not think there is a sensible way to override this, unless you want to duplicate the whole meta box code.

Leave a Reply

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