Put something along these lines in your functions.php:
add_filter( 'pre_get_posts', 'custom_get_posts' );
function custom_get_posts( $query ) {
if( is_category() || is_archive() ) {
$query->query_vars['orderby'] = 'name';
$query->query_vars['order'] = 'ASC';
}
return $query;
}
reference here (see the second answer)
Related Posts:
- Random sort within an already sorted query
- Exclude posts with specific meta_value while sorting by a separate meta_value
- Yearly archive page for future year
- how can i change WP main archives loop to sort by name or title
- how to get post order by post id wp_query?
- How to sort WP_Post Object array by object field in php?
- show image gallery in archives or category page
- Ajaxify Post Sort
- Sort / Filter Queries
- How to get alphabetic listing x other posts, based on first letter post?
- Filter/Sort Post Form On Taxonomy page
- Should we trust the post globals?
- Clear cache when a post is submitted [closed]
- How to Arrange Posts by Size in the WordPress Dashboard?
- Querying post from a multisite network
- How to know if get_posts() failed?
- Show related posts by category but ignore one category
- post__in for get_posts with a dynamic array
- How to sort posts by last name (2nd word) on ONE category only?
- How to get previous 10 days post from a specific date – WP Query
- Post content being duplicated by the_content();
- At my posts archive page, outside the loop, get_the_id() returns the top most post’s ID
- How to add padding between posts
- prevent showing posts of an specific category in admin posts section
- Working Bootstrap Carousel Conversion to WP – Technical Questions
- Link for the page archive for posts, like using custom post types with get_post_type_archive_link
- Plugin for sortable posts in grid [closed]
- Add few specific post ids to wp_query
- How to get the latest posting time of archived pages in WordPress?
- Sort posts by newest child while keeping hierarchy intact
- WP_Query posts_per_page ignored
- wp_query ‘s’ parameter does not work with custom post type
- WP_Query get posts from custom posts by category
- Accessing post->ID outside of the loop for listing child pages
- WP Query – duplicated posts once including tags in search results
- List posts in a given category
- how to get posts ids inside pre_get_posts filter?
- How to display data in archive page?
- How do I use WP_Query to get a range of posts with custom fields that have numbers with letters in them?
- recent posts for different categories
- Search by post title and content in wp_query without order
- Change post order random through out the entire WordPress
- Setup a custom dynamic post
- Anyway to grab author name and featured image in an embeded in inital array of posts outside of loop?
- Removing noindex posts from wp_query
- Archiving by academic year instead of calendar year
- Exclude the first ‘n’ number of posts of a tag from home page?
- wp_query random post
- wp_posts table: safely remove unused columns to save database storage
- Using wp_list_pages() after calling query_posts()
- Possible to alternate between two loops
- Why are my paginated posts always returning the same results?
- Inner join overrides Advanced Custom Fields plugin’s get_field [closed]
- Every second post different class in blog view
- Display posts of specific category term
- Query posts by Author and/or by Tag
- Migrate posts from category and sub-category via SQL
- wp_query with ajax
- Exclude some posts from displaying in wp_query based on some condition
- Sort All Posts by Category Name in the Admin Panel?
- Why does WordPress search returns same number of results for every search query?
- Display in category ( taxonomy) a number of post that I want
- Find out in which kind of archive am I
- How to list post as buch of category, and all of them
- WP_Query get posts in custom database table [duplicate]
- WP query taxonomy optimization
- Override WordPress core post-template.php block template
- Displaying all posts from other sites on the network on one site
- blog post not accesible on click [closed]
- Search results for ACF data
- Multisite how to display merged posts from two sites and sort by latest date?
- Redirect to custom post if custom archive page has just one result?
- Numbered Pagination Showing The Same Posts After Altering WP_Query
- Using a meta_value or postdate to to query and orderby
- Exclude posts in home slider from sections
- view a list of 3 future post, from the nearest to the most far
- Loop through all posts showing duplicates
- Manipulate query to show specific post
- Get current user, change users post status to published
- Random order of the 5 most popular posts
- My custom query is displaying random posts in random order
- Display WordPress Post By Date
- GUID to related post not in current language
- How can I display a specific number of post in a category via a url
- How to display term in archive page?
- Advanced Post Display/Pagination/Ordering
- How to show the posts list into a static page? Problems to use the loop into a static page
- Query category-specific, paginated posts and allow viewer to change sort order
- Sorting Posts by Date – get_blogs_of_user_id()
- Displaying Results From Custom Taxonomy Query
- Make assigning post to a specific category equivalent to assigning it to all categories
- Multiple loops on a Search result page?
- WP_Query retrieve custom posts but not the post showing
- WP_Query: Fetch posts that are in (category1 and not in category2), OR posts that are not in cagegory1
- WP_Query based on a custom field result
- Sort by category and then date?
- How do I show the post title if an advanced custom field hasn’t been used?
- How add class the_content();?
- Display post count on archive page in reverse order
- Filters do not work when there are multiple (one works)