Category Order and Taxonomy Terms Order

Category Order and Taxonomy Terms Order is the free version of Advanced Taxonomy Terms Order, both by NSP Code.
This free plugin has several incompatibilities with facet ordering that the paid version does not have. First, make sure these do not apply to your situation. If they do, switch to the paid version, or to Intuitive Custom Post Order (free). Both do not have these issues.
If you want to use this plugin to order the taxonomy terms for one or more taxonomies, make sure to go through the setup instructions below to preserve the order for facets that use these taxonomies as their data source, and have “Term order” set in their “Sort by” setting.
Incompatibilities
This plugin does not correctly order facet choices in these specific scenarios:
- Using a non-hierarchical taxonomy. Only hierarchical taxonomies will show up in the plugin’s ordering interface.
- Using a Radio facet with a hierarchical taxonomy as data source, and its “Sort by” setting set to “Term order”.
- Using a Checkboxes, Dropdown, or fSelect facet with a hierarchical taxonomy as data source, the facet’s “Sort by” setting set to “Term order”, and the “Hierarchical” setting disabled. For these facet types, the “Hierarchical” setting must be enabled when using a hierarchical taxonomy and “Sort by” set to “Term order”.
In these scenarios, we recommend switching to Advanced Taxonomy Terms Order (the premium, paid version of this plugin) or Intuitive Custom Post Order (free) instead to get correct ordering of the facet choices.
Setup
- First, create (or edit) a facet and set its data source to a taxonomy. You’re going to order the terms of this taxonomy with Category Order and Taxonomy Terms Order.
-

The “Sort by > Term order” facet setting. Set the facet’s “Sort by” option to “Term order”. Only the following facet types have this setting: Checkboxes, Dropdown, Radio, fSelect, Hierarchy, Hierarchy Select, and Color.
-
Next, in Settings > Taxonomy Terms Order, enable the “Auto Sort” setting:

Enable “Auto Sort”. If, for some reason, you don’t want “Auto Sort” enabled, you need to add one of the two snippets below to your (child) theme’s functions.php. Which one depends on if you are using WooCommerce, and if so, how you want to order product categories, because WooCommerce already has its own drag-and-drop ordering interface for product categories.
If you are not using WooCommerce, or if you are using WooCommerce and you want to use the Category Order and Taxonomy Terms Order plugin’s ordering interface for product categories, add the following code snippet to your (child) theme’s functions.php to fix facet ordering when using “Term order”:
How to use custom PHP code?
PHP code can be added to your (child) theme's functions.php file. Alternatively, you can use the Custom Hooks add-on, or a code snippets plugin. More info
// Use only with "Auto Sort" disabled: // If not using WooCommerce, // or if so, to also order product categories with Category Order and Taxonomy Terms Order add_filter( 'get_terms_args', function( $args, $taxonomies ) { if ( isset( $args['term_order'] ) ) { $args['orderby'] = 'term_order'; } return $args; }, 10, 2 ); add_filter( 'get_terms_orderby', function( $orderby, $query_vars, $taxonomies ) { return 'term_order' === $query_vars['orderby'] ? 't.term_order' : $orderby; }, 10, 3 );If you are using WooCommerce, and you want to use the WooCommerce drag-and-drop interface to order product categories, add the following snippet instead. It fixes taxonomy ordering for all taxonomies like the above snippet, but preserves WooCommerce ordering (which happens by a term meta field named “order”). Make sure to also disable “Admin Sort”.
How to use custom PHP code?
PHP code can be added to your (child) theme's functions.php file. Alternatively, you can use the Custom Hooks add-on, or a code snippets plugin. More info
// Use only with "Auto Sort" and "Admin Sort" disabled and “Default Interface Sort” not enabled for product categories: // to order product categories with WooCommerce drag-and-drop instead of Category Order and Taxonomy Terms Order add_filter( 'get_terms_args', function( $args, $taxonomies ) { if ( isset( $args['term_order'] ) && 'order' !== $args['meta_key'] ) { $args['orderby'] = 'term_order'; } return $args; }, 10, 2 ); add_filter( 'get_terms_orderby', function( $orderby, $query_vars, $taxonomies ) { return 'term_order' === $query_vars['orderby'] ? 't.term_order' : $orderby; }, 10, 3 ); - Next, in Your Post Type > Taxonomy Order, order the terms with the plugin’s ordering interface.
- Last but not least: do a full re-index.