Order wordpress taxonomy parent terms by their children count
there should be no need for this function, you could use $args passed to the get_terms. See: https://codex.wordpress.org/es:Function_Reference/get_terms get_terms(‘product_cat’, array(‘orderby’ => ‘count’)); Cheers!