function my_clauses ( $clauses ) {
global $wpdb;
$clauses["join"] .= " INNER JOIN $wpdb->term_taxonomy ON $wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id ";
$clauses["join"] .= " INNER JOIN $wpdb->terms ON $wpdb->term_taxonomy.term_id = $wpdb->terms.term_id ";
return $clauses;
}
add_filter( 'posts_clauses', 'my_clauses' );
function my_orderby ( $where = '' ) {
global $wpdb;
$where = "$wpdb->terms.slug ASC";
return $where;
}
add_filter( 'posts_orderby', 'my_orderby' );