Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // WooCommerce - Attribute order alphabetical by name
- // default order is alphabetical by slug
- 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;
- }
Add Comment
Please, Sign In to add comment