You can pass an array to the query
as the following example described in the Codex shows:
$args = array(
'orderby' => array( 'title' => 'DESC', 'menu_order' => 'ASC' )
);
$query = new WP_Query( $args );
In your case will be something like this:
/* Order Posts Alphabetically */
function prefix_modify_query_order( $query ) {
if ( is_main_query() ) {
$args = array( 'post_date' => 'DESC', 'title' => 'ASC' );
$query->set( 'orderby', $args );
}
}
add_action( 'pre_get_posts', 'prefix_modify_query_order' );
If you want the post_date
as the primary filter, you have to change his position in the array, now the code will query all the posts alphabetically starting by the newest post_date.
Related Posts:
- Order posts (across the whole site) by metadata date
- Filter the query ONLY for the search results page
- Order get_users() by last login date. Is it possible?
- Is it good practice to use wpdb->query() function?
- exclude a category from a search on a specific page
- example of build_query function?
- Shortcode pagination not advancing
- Show Primary Category first when I display post categories
- Ordering posts by publish date not working?
- Create a new query in function.php to filter blog posts
- Connecting to a 2nd DB gives me no results when querying
- How to ignore posts in pre_get_posts?
- get_terms (or tax_query) for term of current post?
- shorthand syntax for custom fields
- Using One Function To Create Two Different Shortcodes
- How to force one script to load before google tag manager script
- Order column custom date using pre_get_posts
- sort title descending with title with number
- Delete oldest wordpress post (SQL query)
- Selecting specific query for offset
- Why isn’t comment validation working?
- Shortcode with pagination advancing multiple queries
- Function returning queried meta value based on current post ID
- Sorting date results from a query
- sort by date in users
- Adding fields to the “Add New User” screen in the dashboard
- Issues with title-tag and document_title_parts
- What’s the difference between admin_url() and get_admin_url() functions?
- How to paginate the get_users function?
- opening links in new tab using – add_filter( ‘the_content’, ‘make_clickable’);
- How to add classes to images based on their categories?
- Child theme – overriding add_image_size by a child theme [duplicate]
- Compare post levels and user levels wishlist member
- Change ul class=”children” for wp_list_pages?
- Target a certain page within wordpress backend (admin) i.e. Pages > About
- Set default options for inserting media
- Session is not starting
- Hide WYSIWYG editor on certain templates
- Trouble using antispambot()
- Polylang: pll_e() & pll__() on functions.php, doesn’t work
- Disable shortlinks like ?p=1234 to prevent scraping
- WP_Remote_Get Not working
- Debugging with functions.php
- Getting first Image from post
- Inserting a functions output after the content
- Combine two different filter callback functions
- Don’t delete a page if it holds users
- How to install Segment on WordPress without a plugin
- How to search using ajax for exact phrase or words in an input field?
- Multisite 404 on pages – rewrite error breaks database
- Dashboard widget custom positioning?
- Need help “sanitizing” a custom function that pulls category slug into body class
- How to get data from an array using get_user_meta()
- Space Not Being Generated in HTML Output?
- Prevent custom field from being updated after first publish
- Do not show on homepage functions.php code needed
- $_Get and &_REQUEST Index Undefined on Functions.php
- Exclude Category ID in function
- get_terms and meta_value results blank
- get_template_directory_uri() links to child theme not parent
- Functions Filter Question [closed]
- get_template_directory() – references parent theme directory
- Dequeue scripts in IE7 only using functions.php
- Why I can’t load my JavaScripts using an hook inside my functions.php file?
- Featured Image keeps cropping
- Function Suddenly Stopped Working
- Prevent creating multiple image resizes in twentytwelve template
- Shortcode of a function
- How to add a shortcode to call a function
- How can I call a PHP function inside a hardcoded shortcode?
- Create a CUstom Archive by Year, but just for a Single Category
- Is it possible to create a shortcode to link to a specific post/page where the tag is just an attribute?
- Malfunction via Safari [closed]
- Is it possible to limit number of files a non-admin user can upload via the WordPress media library?
- How can I connect to a second database and still be able to use wp functions like get_post_types()?
- Display Script in Header When URL Variable Present
- Javascript file loads only on homepage, not on other pages (404 not found error)
- how to check if an element in an html file exists in another html file? [closed]
- Trying to change widgets h-tags
- Getting value of variable from functions.php and debugging it
- Why does echo on functions.php not yield result in source code?
- Child theme, how to cut the functions.php file into several classes?
- use add_action in a shortcode (gravity form – WordPress)
- Setting Up Child Theme To Take Priority
- I want to customize the_posts_navigation function by replacing prev and next with images
- wp_footer hook causing text to show on bottom of page
- Shortcode displaying outside the div [duplicate]
- WordPress reading old version of functions.php, breaks site
- Display ads on post in a particular category
- Using Switch Statement to Change Image According to Last Digit of Topic ID
- Help with is_page() and calling css for specific pages in a Child Theme
- get USER ID in functions.php using user_register action
- How to add an excerpt and read more link to a page?
- WPDB function not saving
- trouble with passing class method data to outside function
- preg_replace specific Text to small latter strtolower [closed]
- Trying to decipher this code which is encoded with HTML Special Characters [closed]
- Which action is triggered before final output?
- How to overwrite image if it already exists – WordPress, Gravity form
- Change TinyMCE undeline outpout