The following should work…
add_action('get_terms_args','my_order_cats',10,2);
function my_order_cats($args,$taxonomies){
//Check we are admin side
if(is_admin()){
$taxonomy = $taxonomies[0];
$screen = get_current_screen();
//Check screen ID and taxonomy and changes $args where appropriate.
if(($screen->id=='edit-category'||$screen->id=='post') && $taxonomy=='category'){
$args['orderby']='id'; //preserves order of subcategories.
$args['order']='asc'; //or desc
}
}
return $args;
}
It preserves the order of subcategories (i.e. children always appear below their parents regarldless if order is set to ASC/DESC).
This could be adapted for custom taxonomies, you would simply need to chhange the $screen->ID
and $taxonomy
checks.
Related Posts:
- How to Change the Categories Order in the Admin Dashboard?
- How to remove categories filter from wordpress admin?
- Weird behaviour when adding terms/term_taxonomies programmatically
- Make parent categories not selectable
- Is it possible to disable certain user roles from creating tags?
- Why adding Categories does not auto refresh in Backend while using my custom theme?
- How to show empty category in admin menus search
- Add a wordpress blog to my website having users
- Collapse subcategories in post edit screen
- Custom order categories in admin dashboard
- Making the category & tag Description textarea bigger
- Filter Categories in meta box for CPTs
- Filtering *out* a taxonomy from the admin post list
- category doesn’t showing up in admin
- WP admin broken. Not saving catgories or adding categories to menu
- Categories in admin interface: can they be collapsible?
- How do I add Category Body Classes to Admin?
- Admin: Navigation Menus do not show empty categories/taxonomies in the list’s search tab
- how i can hide some category from author admin panel?
- How to check a category checkbox using JavaScript
- wp_category_checklist won’t show up for non-admin users
- How to load jquery tag-it plugin into admin?
- Assign a category by user and customize the edit-tags.php?taxonomy=category page
- Show parent-child relationship for categories in the wordpress admin
- List all subcategories from category
- Remove parent category from permalink? Basically only have the child category?
- Filter by post category in Media Library
- Force WordPress to Show Pages Instead of Category
- Display all posts in category, with specific tag posts at top
- Send an email when custom post type category is changed
- How to Set an Individual Homepage for Each User?
- Is there a way to remove categories in bulk?
- Remove specific category from a post
- Is it possible to put next and previous category links?
- Getting category before saving post
- Attachment page per category
- How to get the depth of a category’s subcategories
- Best way to programmatically link to multiple categories (union/intersection) [closed]
- WordPress Multisite – global categories
- Code to pull in a PHP file named after the category ID
- functions.php conditional tag – only show in single.php?
- Get categories from save_post hook
- Need to pull parent category and slug – only pulling daughter category
- Category location styling
- WordPress category page redirects in .htaccess not working
- Category archive rewrite rule to include category/subcategory?
- How can I automatically display a visual archive of subcategory posts [and thumbnails] separate from Parent category?
- Change thumbnail image depending product category
- How to organize custom categories for filtering and selecting
- Woocommerce custom category pages
- get_next_post set the category
- Different menu navigation per category
- Get category URL knowing it’s id
- How could I know all the categories from post?
- How to make subcategory for custom post and and display?
- Create menu locations for each category in wordpress
- How to make the ‘delete’ button inactive on some categories?
- Notice: Trying to get property of non-object in : custom fields category
- Array: What is this value based on?
- Show testimonials based on post category matching product name
- WordPress list categories dropdown with parent-child relation and child under it’s parent
- How to Link to Most Recent Custom Post of Same Term
- WP REST API not retrieving all categories
- Category page not showing
- How to only show parent categories in sidebar
- Change RSS format for specific categories
- Displaying a custom field in Category Archives
- List post only under the category, exclude child category content
- Custom Portfolio Page
- Custom Fields Value As Taxonomy
- Detect category choice for posts with multiple categories
- Redirect Problems with Archive Page and GET variables
- Different size video display for category page (smaller) & detail page (larger)
- Adding tinymce to Custom Field boxes on Category edit page
- wp_list_categories : how do I sort by ID when IDs are not sequential
- Showing different posts on category pages
- How do you get sticky posts to work with categories?
- How to exclude certain categories showing in Gutenberg?
- Display the articles of a category by role
- Remove “Category:” from Post meta
- restrict category to only logged in User
- Category and tag urls return 404 error
- Default category isn’t saved in database
- Dynamically creating content on custom URL without getting 404
- Category foreach Paging
- Display all of a post’s categories except the current category
- One category not displaying template updates
- How to display only category of blog without custom code?
- How to create a category or tag available exclusively to the admins and not to the users?
- Matching usermeta at registration to categories of content
- wordpress category.php query for featured news item, broken pagination and repeating posts
- How do I hide posts in a category from all listings but still allow the posts to be viewed?
- Form Value of drop down category + Translation of ‘show option none’
- Echo class depending on Parent category
- Query pages by category
- List all authors by matching custom meta data on a category page
- How to show monthly archive posts?
- How to display posts by author in a separate page, other than author.php?
- One color to category link depending on category ID
- Show subcategories and hide posts or show posts if not exists subcategories