If you are using the Intuitive Custom Post Order plugin to order your taxonomy terms, use the code below to preserve that order for facets that use terms.


First, edit your facet (Settings > FacetWP) and set the “Sort by” option to “Term Order”.

Next, add the following code into your (child) theme’s functions.php, or use our Custom Hooks add-on:

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

add_filter( 'get_terms_args', function( $args, $taxonomies ) { if ( isset( $args['term_order'] ) && 'order' !== $args['meta_key'] ) { // The second condition is needed to preserve WooCommerce ordering for product categories, by a termmeta field named "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 );

See also