Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // Sorts attributes alphabetically on the Attributes page and in the select dropdown on product pages
- // not tested exhaustively!
- // Code goes in functions.php of your child theme
- add_filter('woocommerce_attribute_taxonomies', 'custom_attribute_sort');
- function custom_attribute_sort($array) {
- usort($array, 'compareName');
- return $array;
- }
- function compareName($attribute_1, $attribute_2) {
- if ($attribute_1->attribute_name == $attribute_2->attribute_name) {
- return 0;
- }
- return ($attribute_1->attribute_name < $attribute_2->attribute_name) ? -1 : 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement