Sort by name – second wp_query

Posts are not sorted alphabetically, because you don’t tell WordPress to sort them in such way. By default they will be sorted by date in descendant order (newest first).

What you should do, is change your WP_Query args by adding order and orderby, so it should look like this:

$args = array(
    'post_type' => 'os_book',
    'orderby' => 'title',
    'order' => 'ASC',
    'tax_query' => array(
        array(
            'taxonomy' =>  $term->taxonomy,
            'field' => 'id',
            'terms' => $term->term_id
        )
    )
);

PS. You should sort them by title and not by name, I guess. Results of these 2 methods can be different and sorting by name won’t give you correct alphabetical order in every case (i.e. it will ignore accents).

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