My Problem is trying to pull the size attributes for the different products. So, for that i used this php code
<?php
$terms = get_terms('pa_size');
foreach ( $terms as $term ) {
echo "<li>" .$term->name. "</li>";
}
?>
The size attributes displaying for the above code should be in alphabetic order such as like L, M , S , XS instead of XS, S, L, M, XL, XXL. Help me out from these.
Use asort()
For Testing purpose.
Demo
array before sort
array after sort
Terms are ordered alphabetically by default however WooCommerce applies a filter which changes the ordering.
To change the order back to alphabetical you need to set
menu_order
to false in your arguments forget_terms()
.Example: