• Hello,

    I’ve made a custom posttype with its own set of categories. I’ve got a bunch of categories – some with children categories and some without. Is there anyway to sort the parent category alphabetical and make them collapse their child categories in the admin panel/post editor?

    I haven’t been able to find a piece of code or plugin, which can do this, so any help would be appreciated.

    Thanks in advance

    • This topic was modified 5 years, 4 months ago by Jan Dembowski. Reason: Moved to Fixing WordPress, this is not an Everything else WordPress topic
Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    The categories should already be alphabetical after the selected categories are placed on top. Collapsing the children is entirely another issue. The expand/collapse functionality would need to be implemented with custom JavaScript which alters the CSS display property. The thing is though that there is nothing obvious for the user to interact with to expand/collapse or to indicate there are hidden children. You can add such elements through a custom walker whose class name is injected into the process through the ‘wp_terms_checklist_args’ filter. You can extend the Walker_Category_Checklist class to create your custom walker.

    The only difference would be including an arrow or +/- element to items with children. It might be easier to add these elements with jQuery instead of a custom walker.

Viewing 1 replies (of 1 total)
  • The topic ‘Post editor: sort and/or collapse categories’ is closed to new replies.