Have you ever wanted to sort your categories using drag and drop? Have you ever used a plugin that implements some sort of custom taxonomy or custom categories but no drag and drop sorting support?
Then, that plugin is for you. Using it you can enable categories custom ordering using drag and drop. But not only, you can set it to enable custom ordering of any other taxonomy’s terms, even taxonomies created by other plugins.
To enable ordering terms of a specific taxonomy add this code to your theme’s function.php file:
if( function_exists('add_term_ordering_support') ) add_term_ordering_support ('the_taxonomy_name');
To remove support for a specific taxonomy:
if( function_exists('remove_term_ordering_support') ) remove_term_ordering_support ('the_taxonomy_name');
To check if terms ordering is enabled for a specific taxonomy:
if( function_exists('has_term_ordering_support') ) $enabled = has_term_ordering_support ('the_taxonomy_name');
Don’t worry about providing terms ordering support to your plugin’s custom taxonomies. Just point you users here to install our plugin and add those line to your plugin:
if( function_exists('remove_term_ordering_support') ) add_term_ordering_support ('your_custom_taxonomy_name');
Using the get_terms function
By default the
get_terms() function will sort custom ordering enabled taxonomies by their custom order first, and then by the value of the ‘order’ parameters given to that function.
To control how the sorting is done use the new ‘menu_order’ parameter. By default it is set to ‘ASC’, you can set it to ‘DESC’ or to false to disable custom ordering.
Want to contribute? That plugin is on GitHub.