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).
Related Posts:
- Find out total number of pages in global query on archive page?
- Resetting post data to previous loop in nested loops
- Order by multiple meta key and meta value [closed]
- Is it possible to completely stop WP_Query retrieving posts?
- Order by optional meta key?
- Make loop display posts by alphabetical order
- WP_query to get the first two latest posts, then another loop to get the next three
- Why is WP_Query not working with category_name?
- ‘Trying to get property of non-object’ when using WP_Query with ‘fields’ => ‘ids’
- Displaying several specific pages using WP_Query()
- WP-CLI How to generate a list of posts with corresponding meta values
- Query to return maximum of one post per author
- Get attachment by slug
- RSS feed with specific keyword
- Get All IDs Of A Post Type Using WP_Query
- Warning: urlencode() expects parameter 1 to be string, array given
- Group posts by custom field
- Multiple endpoints in one URL
- How to get the posts published in last two days using WP_Query?
- getting posts and number by specific meta value in multiple meta
- How to query using a combination of custom_field values?
- Get attached media only
- Can not switch the queried post in pre_get_posts hook
- how to fire join query with post_meta
- Show one post per author and limit query to 8 posts
- Get term by custom term meta and taxonomy
- SELECT * FROM $wpdb->posts WHERE ID > 160
- How to show the posts of some category first, and then all other
- Explanation of WP_Query
- Pagination problem after WP_Query with tag filtering
- Custom Loop in Page Admin Causing Other Fields to Fail
- Pagination stops at page 6
- Paginated HTML Sitemap
- How to limit total number of posts in wp query loop?
- How to get posts on a specific date – WP Query
- WP_Query no posts with tax_query
- Get list of terms that have posts in another term
- WP_Query with Metavalue
- My Main Query Modification is Messing up my dynamic main – why?
- WP_Query meta_query >= date
- Using Ajax to load more posts | Help me change the wording on my button to notify the user
- WordPress add_rewrite_rule() cannot visit lower url levels
- Get a post from other loop each n-posts in the main loop
- Search for multiple tags?
- paging in WP_Query on static page
- WP_Query() and get_posts() can’t handle over a thousand posts?
- Query by multiple meta elements not seeming to work – wordpress is timing out
- Sort by price woocommerce by ID post_meta
- Cluster WooCommerce products in each Category Archive by Tags assigned to products
- Post loop for all taxonomy terms
- Which is faster wpdb & get_row or wp_query & ge_post_meta?
- Why is WP_Query not displaying expected data?
- Customy WP Query Args are convertet in SQL result
- Filter post query to only show direct children of category
- Highlight current post title on a page
- Why won’t draft listings appear for non-admins?
- My WP_Query didn’t work after upgrading to WordPress 3.2
- meta queries do ‘either/or’ checks
- search serialised meta_value for date value?
- has_excerpt() not working inside wp_query
- Apply query arguments after the nth post
- How to properly use AND / OR in custom search
- Get post and its children with WP_Query
- wp_trim_words strips dashicons
- Get every post with value in meta key
- Using get_posts to get posts based on a checkbox value with Advanced Custom Fields
- Searching by title, content and custom taxonomy
- Storing an array of objects related to each user
- How to get posts by category and by choosing a taxonomy term?
- Paging + WP Query
- Getting the permalink to the latest post from a category
- How to restrict search on a certain page to only return results against custom taxonomies?
- Can’t order the query result as given posts id’s array
- Deleting terms from the WordPress wp terms table
- In a WP_Query can I force the results’ is_singular() to be set to false?
- My combination of ‘post_type’ and ‘tax_query’ not working?
- Query pages created by deleted users
- Get posts that match defined arrays of tags
- WordPress live search and filter
- Display posts from multiple value in meta separated by comma
- WooCommerce. How To Exclude Subcategory Products From Category Listing Page
- Why can my filter query SOME metadata but not other metadata?
- The query show user list orderby count published posts in last month
- WordPress – Form does not filter the results of taxonomies
- Show one post of each custom taxonomy
- wordpress multiple meta value query is not working
- trying to change from query_post to WP_Query
- Sorting Posts by Taxonomy thats not within the query’s $args
- Order Posts By Custom Field That is an array of objects
- Rewind posts then show only first post
- Ordering Posts by parent category, name ascending
- Use not custom fields in get_posts() meta_query?
- WP_Query Sorting Posts by month … timeline effect
- why is this query returning entire blog-posts
- Including ‘cat’ => $cat breaks meta_query
- problem in query_vars parameters
- Limit Tags display and ad Drop Down Menu
- Query posts only shows 1
- First post outside of loop, homepage only?
- WP_Query filter Posts by timestamp event (range start and end) and by month (next 12 month)