I’ve followed the instructions found on the official WordPress site to create a page that shows a sorted list of one of my taxonomies. It works just fine, except I’d really like to have Natural Sorting if possible, but in the wp_list_categories
function, the only valid options for the “order” argument are “ASC” and “DESC.”
I’ve tried modifying the function by applying a natural sort to the array using the following without success (returns an error):
$categories = get_categories( $r ); // this line is part of the original function
foreach ($categories as $key => $row) {
$sortNames[$key] = $row[1];
}
array_multisort($sortNames, SORT_NATURAL, $categories);
Here’s what the first element of the $categories
array looks like in a dump (I’m sorting by “name”):
array(389)
{
[0]=> object(stdClass)#363 (15)
{
["term_id"]=> &string(3) "541"
["name"]=> &string(17) "2° Ms. astron. 1"
["slug"]=> &string(13) "2-ms-astron-1"
["term_group"]=> string(1) "0"
["term_taxonomy_id"]=> string(3) "567"
["taxonomy"]=> string(13) "manuscript-id"
["description"]=> &string(0) ""
["parent"]=> &string(3) "540"
["count"]=> &int(1)
["cat_ID"]=> &string(3) "541"
["category_count"]=> &int(1)
["category_description"]=> &string(0) ""
["cat_name"]=> &string(17) "2° Ms. astron. 1"
["category_nicename"]=> &string(13) "2-ms-astron-1"
["category_parent"]=> &string(3) "540"
}