Sorting Custom Taxonomy in ASC/DESC order?

If you really need to sort by taxonomy term, I think you have a bad design of the data structure in your application. Think about it.

A taxonomy is a way to group things, lets say posts. A taxonomy is a group of “terms” and the posts are grouped by the shared “terms” between them. From my point of view, if the terms are used as they should be, sorting by terms is not useful at all and have no sense.

Lets go with an example in your page: You can filter by “Codecademy” platform, so you get the group of items assigned to “Codecademy”. Then you click in the “platform” table header to sort by “Codecademy”, where the logic is?. It is like having a group of “dentists” that you want to sort by “dentists”; you may want to sort by something that describe each dentist, like name or cost, but not by “dentists”. Do you get my point? If you need to sort by some posts characteristic, you should use customs post meta fields or core post fields, not taxonomies.

Another example, if you want to sort alphabetically by the “platform” taxonomy, what you really want is sort the terms of a taxonomy alphabetically and the show the posts for each term, this is not sorting the posts, it is sorting the terms.

Anyway, if you really want to sort by taxonomy term you can do it, not by a standard way provided by WordPress but by a custom way like your workaround in the custom SQL you are using or the example of this article.

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)