#39457 closed defect (bug) (duplicate)
Custom order of categories in Admin (post.php, post-new.php) broken in 4.7
Reported by: | lectest1 | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 4.7 |
Component: | Query | Keywords: | |
Focuses: | Cc: |
Description
Pre-4.7, this worked to order categories (and other taxonomies) in admin views such as the sidebar checklist at post.php and post-new.php, and the admin ‘Categories’ page, itself:
// Order list of categories in admin views
function my_sort_terms( $args ) {
$args['taxonomies'] = array( 'category' );
$args['order'] = 'DESC';
$args['orderby'] = 'id';
return $args;
}
apply_filters( 'get_terms_args', 'my_sort_terms', 10, 2 );
However, when I upgraded to WP 4.7, it stopped working.
I’ve deactivated plugins on my main sites. I, then, tested on a stripped-down test site on 4.6 and 4.7 – same result. 4.7 stops this from working. Neither ‘add_filter’ nor ‘apply_filters’ works.
How to fix? OR, in 4.7, how would you order categories/taxonomies by id on the admin side?
Categories (and other custom taxonomies) are stuck in alphabetical (name) order in the admin. What's needed is a way to order by id (and other properties).
Result in 4.6 for the 'New Post' sidebar category list:
April (term id = 200 )
March (term id = 195 )
February (term id = 194 }
January (term id = 193 }
Now, in 4.7 for the 'New Post' sidebar category list:
April (term id = 200 )
February (term id = 194 }
January (term id = 193 }
March (term id = 195 )
Again, my test site has no non-core plugins, no custom functions, except for the above, and is running Twenty Sixteen theme.
Hi @lectest1 - Thanks for the details. Your code is working as expected on the latest trunk, but not on 4.7. It appears that the issue was resolved with [39625]; see #39354. Please test against this latest version.
(For reference, it's probably a bad idea to blindly override the
taxonomies
parameter in your callback. This will make it impossible to query for any taxonomy other than 'category'. You may want to have some sort of fine-grained check there.)Please do reopen this ticket if you're able to reproduce against trunk (or with [39625] applied manually to your installation).