Viewing 2 replies - 1 through 2 (of 2 total)
  • You’ll need a snippet to do that:

    add_filter( 'woocommerce_attribute_taxonomies', 'custom_attribute_sorting' );
    function custom_attribute_sorting( $attribute_taxonomies ) {
      usort( $attribute_taxonomies, 'sort_by_attribute_label');
      return $attribute_taxonomies;
    }
      
    function sort_by_attribute_label( $a, $b ) {
      if( $a->attribute_label == $b->attribute_label ){ return 0; }
      return ($a->attribute_label < $b->attribute_label) ? -1 : 1;
    }
    Thread Starter konsument

    (@konsument)

    Hi and thanks for your reply. Since I need a custom order I did it this way

    
    $order = array(6,1,2,3,4,5,0);
    uksort($attribute_taxonomies, function($a, $b) use ($order) {
    return (array_search($a, $order) > array_search($b, $order));
    });
    return $attribute_taxonomies;
    

    I just was hoping theres a way to sort them in backend somehow.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Sort Attributes (not terms)’ is closed to new replies.