3

By default whenever you select a category it moved it to the top of the term list, which in most cases it pretty user friendly. I want to disable this featured and leave my term list in the default order no matter what is selected.

The reason I want this is because i have a script running that relies on <ul class="children"> to be available, but if a term is selected it removes it from this format and to the top of the list. I've search around but wasn't using the correct keywords to pull anything useful. I'm sure I need to do something with the Walker_Category_Checklist Walker but walkers are very much a mystery to me.

I'll be playing around with that and some WordPress files to find how what function is pushing it to the top but in the meantime I figured if anybody has a solution on-hand: How do I disable WordPress pushing selected terms to the top of the Post Category Metabox?

1 Answer 1

8

Try adding this in your functions.php file:

// Let's stop WordPress re-ordering my categories/taxonomies when I select them    
function stop_reordering_my_categories($args) {
    $args['checked_ontop'] = false;
    return $args;
}

// Let's initiate it by hooking into the Terms Checklist arguments with our function above
add_filter('wp_terms_checklist_args','stop_reordering_my_categories');
2
  • 1
    Fantastic, I'm glad this was an easier fix than I thought ( and there's no custom walker involved :D ). Thanks!
    – Howdy_McGee
    Jan 16, 2015 at 14:30
  • Very helpful, thank you. Can confirm it works in WP 4.4.2. Mar 23, 2016 at 16:50

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.