2

I setup some hierarchical categories and when I assign them to a post the widget reflows and loses the hierarchy display. Example:

- Education Services
-- Arts & Archives
--- Fine Arts
-- Reference
-- Health Sciences

When selecting "Education Services" & "Reference" (marked with 'x') the widget appears like this:

x Education Services
-x Reference
- Arts & Archives
-- Fine Arts
- Health Sciences

So since the selected (top-level) parent goes to the top, all children besides the selected one look they have lost their parent (even though they actually have not).

I have read some other forums post/support tickets but not much about this issue. Any suggestions?

3
  • I'm confused about what's happening. Can you post some of the code or a link to the site? What widget are you referring to?
    – Michelle
    Commented Aug 16, 2011 at 19:33
  • if you are still curious see the Trac reports t31os linked below. Commented Aug 18, 2011 at 12:51
  • Ah, gotcha! When you said 'widget' I assumed you were talking about how the categories display on the front end. I'm with you - that's a very annoying 'feature'. I've had clients complain in the past and never knew how to describe what was happening much less fix it. Great question!
    – Michelle
    Commented Aug 18, 2011 at 15:23

3 Answers 3

2

You could try out Scribu's plugin, i believe this addresses the very problem you're describing which has been reported on Trac a handful of times(but closed/deleted).

Category Checklist Tree by scribu
http://wordpress.org/extend/plugins/category-checklist-tree/

Related tickets:

Hope that helps.. :)

5
  • thanks. i saw various forums posts that were closed/un-answered also. i will give this plugin a shot or just end up re-working my idea i suppose. Commented Aug 18, 2011 at 12:51
  • If necessary you can always unregister the metabox and create your own that sorts them differently(if you're into doing that). :)
    – t31os
    Commented Aug 18, 2011 at 21:10
  • 2
    The "Category Checklist Tree" plugin hasn’t been updated in over 2 years. It may no longer be maintained or supported. Please consider using this new plugin: wordpress.org/plugins/categories-in-hierarchical-order as a replacement.
    – Guicara
    Commented Oct 31, 2016 at 9:54
  • I can confirm that "Categories in Hierarchical Order" works and has been tested with WordPress v 5.2.2. Thank you for the note Guicara! Commented Aug 28, 2019 at 8:15
  • You're welcome!
    – Guicara
    Commented Aug 28, 2019 at 8:22
4

Based on the plugins Category Checklist Tree and Categories in Hierarchical Order, you could directly use this filter in your function.php file without adding any plugin:

add_filter('wp_terms_checklist_args', function($args, $idPost) {
    $args['checked_ontop'] = false;

    return $args;
}, 10, 2);

It is also possible to apply this filter only to a specific taxonomies:

add_filter('wp_terms_checklist_args', function($args, $idPost) {
    $taxonomies = ['foo', 'bar'];

    if (isset($args['taxonomy']) && in_array($args['taxonomy'], $taxonomies)) {
        $args['checked_ontop'] = false;
    }

    return $args;
}, 10, 2);
2
0

I developed a plugin that solves this problem. Besides preserving the hierarchy of categories, this plugin adds a toggle style the category tree.

See the official plugin page: http://www.rafaelmarques.com/wordpress/plugins/wp-best-tree/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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