Skip to content

Instantly share code, notes, and snippets.

@clifgriffin
Created August 30, 2013 13:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save clifgriffin/6389910 to your computer and use it in GitHub Desktop.
Save clifgriffin/6389910 to your computer and use it in GitHub Desktop.
Leverage https://gist.github.com/clifgriffin/6389814 to sort terms naturally on post edit screens.
<?php
add_filter('get_terms_orderby', 'reorder_categories_admin', 20, 2);
function reorder_categories_admin($orderby, $args)
{
global $pagenow;
// If not category, bail
if ( ! isset($args['taxonomy']) || $args['taxonomy'] != 'category' ) return $orderby;
if( is_admin() && ( $pagenow == "post-new.php" || $pagenow == "edit.php" ) ) {
return 'natural';
}
else {
return $orderby;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment