On the template driving your archive page, you can use the query_posts()
function to adjust the main query (WordPress’ default main query, not your custom one).
query_posts( array(
'orderby' => 'modified',
'order' => 'ASC',
) );
Using the pre_get_posts
action is the better method, though slightly more complex (untested, would go in theme’s functions.php
or an mu-plugin):
add_action( 'pre_get_posts', static function ( $query ) {
if ( ! $query->is_main_query() || ! $query->is_category() ) {
return;
}
$query->set( 'orderby', 'modified' );
$query->set( 'order', 'ASC' );
} );
Related Posts:
- Query Posts in a Predefined Order
- Order posts by ID in the given order
- WP_Query ordered by custom field that is a date string?
- How can I pick a single post from the latest 3?
- Order by meta date with a thousanth of a second defaults to post order
- How to order posts, that have already been filtered by custom taxonomy, by their category names?
- query_posts with sorting on a custom datestamp
- Nested meta_query with multiple relation keys
- Ignoring initial articles (like ‘a’, ‘an’ or ‘the’) when sorting queries?
- WP_Query vs get_posts
- Order by optional meta key?
- Sorting: custom query with orderby meta_value_num THEN by title
- Using OR conditions in meta_query for query_posts argument
- Sorting posts by custom date fields (non standard date format)
- Query Multiple Post types each with own meta query
- Get posts by menu ID
- Get the number of posts from the current page results
- How to know which one is the main query?
- Meta Query with date and time on the same Day before given time
- WP_Query sort by comment meta data
- Order posts by tags count?
- Orderby = none not working [duplicate]
- WP_query ‘orderby=none’ Problem
- Multiple search queries on one page
- Ordering by meta_value AND date NOT WORKING with wp_query
- WP_Query orderby breaks when using AJAX?
- How do you query wordpress posts using a math formula between multiple meta field values?
- How add a custom posttype name using ACF field to a query post array
- Custom Post order for homepage
- Change default ordering of taxonomy terms – pre_get_terms
- Page navigation doesn’t show when query category
- 2 loops on page – one with orderby rand second orderby date
- Custom category search box for WordPress
- Sorting posts DESC based on the number of comments using WP_Query
- Query with a meta value inside a given range
- (Solved) WP_Query ($ args) -> How to sort letters and numbers within the same array
- Five posts from a category in footer
- How to set multiple `orderby` in query argument?
- How to display multiple custom fields with the same meta_key in an ascending order?
- WP_Query: Group events by year, sorted DESC; then by date for each year group, sorted ASC
- Order by summing multiple values
- Understanding the orderby in WP_Query?
- Order by empty custom field
- Help ordering Post loop by two meta values
- How to display an other custom post type in a different custom post type’s archive?
- How to exclude post formats from wordpress recent posts in a tabs widget [closed]
- How to increase load time of an archive/search page (WP_Query)
- Query Page Content From Theme Options?
- Exclude All Posts Which Do Not Have A Tag Assigned
- Ordering posts by an array
- How to Create a Random List of Child Pages
- Easy way to write complex queries in wordpress
- get_posts output always same post
- Query_posts works when appending via AJAX call wp_query doesn’t?
- How to make posts unqueryable/unpublish posts where ACF relationship field is an unpublished post? [closed]
- complex get_posts() query to select child pages
- Child pages not affected by orderby
- Get next/prev image/attachment in time with date query
- WP_User_Query orderby meta_val_num
- Sorting posts by Multiple custom fields in defined order
- specific post is not excluded from the loop
- Why doesn’t my WP Meta Query return any results?
- WP_Query orderby random do not repeat infinite scroll – one loop
- Trouble Making WP_Query paged
- Determine if ID is page or post and query the ID
- How to query for a page, get data, then query for child pages of that page
- Sort posts using multiple custom fields and menu_order in single query?
- Optimising WP_Query with ACF Fields
- Filter products on category AND tag
- Query post ordered by meta value that show first post that contained a tag
- How can I order a post query’s results based on the number of matching taxonomy terms?
- How to sort wordpress posts already selected by WP_QUERY
- pre_user_query vs pre_get_posts
- Custom WP Query order function possible?
- How do I stop the same post showing multiple times in a archive?
- Meta query orderby meta_value_num sorting by role first
- Order by value of Custom Field using url string
- Order posts by tags count?
- WP Query with meta queries
- Order Element By Custom Field in WordPress
- trying to change from query_post to WP_Query
- Sorting with meta_query and multiple, optional meta keys
- WordPress For Loop Prints Unwanted Extra Paragraph Element
- My entry results are not consistently alphabetized
- query_posts() doesn’t seem to be called in my page
- Some doubts about how the main query and the custom query works in this custom theme?
- orderby in WP_QUERY – Use the order from the Dashboard
- Fetching $_POST from Page Template into functions.php
- How to order by datediff in WP loop?
- Ordering Posts by parent category, name ascending
- Using orderby with 2 meta keys
- Optimising specific Query with ACF meta objects
- Query Posts by date range with fixed beginning and end
- Posts2Posts, wp_query and orderby issue
- Exclude categories and subcategories in QueryLoop
- Change posts archive ordering
- Get posts that were most recently tagged
- WP Query – Show custom posts only if user contain some user meta
- Show number of posts AND number on current page (cannot make it work)
- Why does wp_query only display the most recent post when using order ASC?