You haven’t specified where you want this alteration to apply to so I’ve applied it to just the home page. You may alter to fit where this filter applies to:
<?php
function wpse10691_alter_query( $query )
{
if ( $query->is_main_query() && ( $query->is_home() || $query->is_search() || $query->is_archive() ) )
{
$query->set( 'orderby', 'modified' );
$query->set( 'order', 'desc' );
}
}
add_action( 'pre_get_posts', 'wpse10691_alter_query' );
?>
Place code into theme functions.php or package into a plugin.
Related Posts:
- Alter query on edit.php
- Does wp_query and query_posts affect website performance? [duplicate]
- the_date() not working
- Query multiple custom post types in single loop
- The correct method to pass query vars in AJAX using ajaxurl
- How to search display_name column when using WP_User_Query
- wpdb::prepare was called incorrectly
- Using WP_Query – how to display something IF there are no results
- How to order WP_User_Query results to match the order of an array of user IDs?
- Build a content and excerpt grid loop with paging and options for # of posts
- How to find objects by terms
- How to create a WP_Query to search the Title or Tag?
- Delete post revisions on post publish
- Getting movie and serial on actor page
- How to get user by display_name with WP_User_Query
- How to sort results from a custom database table
- Specific Loop For 2 Within Each
- Two posts in same div – WP loop
- how to display active, upcoming and past event with featured listing with pagination
- WP database error for comments_popup_link()
- How to add a post or page tag to the list of classes appearing in the body tag’s class attribute?
- Use two WP Query in template
- my function doesn’t return my post from today
- Include a specific post to the query_posts and remove it if it is already in the returned list
- Display related products with custom output
- Get ID of child from child slug, while knowing parent ID
- Insert all post IDs in new database table
- List User order by ID in Descending order (Backend)
- spliting posts into two columns
- How to get to a specific position in wp_query?
- Exclude posts from homepage having a specified tag
- WordPress – query 5 posts with a specific post in top
- Multiple choice in a custom taxonomy
- Get all user meta by meta key instead of ID
- Working with query_posts ( arrays and query strings)
- Why is variable not working on custom sql query using wpdb?
- How to get a list of all possible values of a specific user meta key?
- Can’t search posts using WP_QUERY inside AJAX Function
- Get stock by custom meta field on all Woocommerce variable products
- Any possible way to make $wpdb->get_results() return anything else than array?
- Custom filter in admin edit custom post type responding with invalid post type?
- Accessing the database from a plugin outside of action hooks
- Echo a hierarchical list of post data from custom fields
- Displaying the last post on static homepage
- Create WP_Query to search for posts by their categories or their parent/child categories
- WP Query with custom Shortcode
- Storing Array from returned database query and using the array in a new query
- Using loop pagination on single.php
- Logged in user ID as post ID
- mysql query from wordpress page using custom table
- Sort query_posts for Parent Pages to menue order or the count?
- WordPress 3.2 query_posts and pagination, permalinks issue
- only show container with next/prev links if they exist?
- What query string parameter is available for index.php, that works for both pages and blog articles?
- ACF: how do I get the fields and its values of a specific group?
- Set WP_query ‘order’ option by another tables value
- WP_Query adds “(wp_posts.ID = ‘0’)” so no results are returned
- WordPress default Search function inconsistent in WooCommerce Product Titles
- Increase offset while looping
- Long running queries
- wpdb php get_var query to get ID for URL image doesn’t work for ID over 999
- How to pre populate a form field with a link of a current user’s author profile?
- Two queries for a WP_User_Query search work perfectly apart, but not together
- Trying to get a PHP variable defined in a custom post into a javascript file. Null value. Using wp_localize_script
- Query if audio attachment AND/OR custom field
- Using $wpdb (WPDB class) ‘replace’ with multiple WHERE criteria problem
- register_taxonomy() take much queries
- Sort by page information by Ascending Numbers
- WordPress SQL injection
- Which is the correct way to conditionally enqueue a CSS file?
- Odd / Even posts add class minus first post
- How to list posts from a plugin taxonomy?
- unable to use ‘new WP_Query’ in AJAX call
- Counting Search results, and displaying the offset per page
- How to get post ID in a Page?
- Parse error: syntax error, unexpected ‘}’ on get_the_author_meta [closed]
- How to list commenters and days since last commented
- How to add div blocks after certain set of post
- How to overwrite orderby with add_query_var
- Can’t update multiple rows with $wpdb query
- Pagination broken on is_front_page()
- working with term_relationships table
- WordPress query undefined offset in loop
- Can I make get_users() query global?
- Issue with custom loop in Archive page
- How to display SQL query that ran in WC_Order_Query?
- Custom Post type slider with thumbnail navigation
- Parse error: syntax error, unexpected ‘}’ [closed]
- change the default order of posts only for specific categories
- Shortcode to pull posts
- PHP -> SQL Query with Summing
- How to hide posts of a specific custom category in WordPress?
- Posts are not looping through correctly
- WordPress PHP syntax doesn’t seem to be working correctly
- Querying for specific tags
- How to get thumbnail with pure PHP in a WordPress database?
- Limit tags shown in post
- Why my query does not run with prepare
- limit number of post for achive page
- Saving a post ID to use in a form elsewhere on website