You can use filter posts_clauses
For example:
add_filter( 'posts_clauses', 'post_query_order', 20, 1 );
function post_query_order( $pieces )
{
global $wpdb;
$pieces['orderby'] = $wpdb->prefix.'posts.post_type ASC';
return $pieces;
}
Related Posts:
- Filter and Search
- Filter results with custom field values and dropdown
- Search with filters and title
- Add Dropdown menu using “add_filter => wp_nav_menu_items”
- Search pre_get_posts filter which can handle multiple post types and categories?
- Filter keywords from search query
- Add filter to wp_dropdown_pages() or wp_dropdown_categories() – no select container?
- Ignore dots when searching in the media library?
- Why anything done on comments_array hook gets reset?
- Adding id and class to the search input in WordPress search form
- Sorting and limitation with pre_get_posts
- How to apply filter at search of woocommerce products?
- Dropdown filter in custom posts
- How to edit dashboard search posts button texts for my CPT?
- Filter Media by Featured on Admin
- Filter custom post type using multiple taxonomy dropdowns
- How can I make a search form that can search taxonomies and posts?
- page_attributes_dropdown_pages_args filter does not work
- Admin Backend – Search Pages only by title
- Comment search plugin
- Create Search Form to Filter Through Terms
- Map plugin with proximity search compatible with Buddypress
- How to trim white space in search terms?
- Sorting products by price ( regular + sale price )
- conditional search
- How to set a filter search for categories of blog posts in wordpress
- Customising the default wordpress search functionality
- Drop down filter sort posts by latest, last 7 days and monthly
- Search with filters
- Modify WordPress search behaviour in backend?
- how to develop a filter in wordpress to let the user filter the page content depends on the date (newest to oldest etc…)?
- Re-order search results with posts_orderby filter and post meta value
- meta box loop problem with a search filter
- Remove the post_content search from WHERE clause (and CONCAT sql function)
- Custom search fields and AJAX support
- How we make the filter for fornt end user
- Taxonomy search filters
- Filter posts by multiple checkbox categories
- How to elect position of new item output in a dropdown when using add_filter
- Search and Filter Using Custom Post Type, Custom Taxonomy, and Advanced Custom Fields
- Sanitize and data validation with apply_filters() function
- remove_filter( ‘the_content’, ‘wpautop’ ); only for certain post types
- Custom search filter causes menu and query_posts problems
- Valid characters for actions, hooks and filters
- How to hook into unregistering a widget instance?
- How do I use the ‘http_request_host_is_external’ filter
- get_option() filtering and getting out of recursion
- AJAX filter posts on click based on category
- Can I add custom meta for each image uploaded via media-upload.php?
- How do I know if author field was changed on post save?
- WordPress Search Custom Meta Field Only
- Some questions regarding filter
- Problem getting single_template filter to work – I want to serve a different single.php file for posts in a certain category
- Too many actions/filters!
- Which hook is fired when inserting media into a post
- How to specify which category of the post to use in case of multiple categories
- How to add a class to Tag cloud widget link?
- How to get all the predefined do_action() calls from an active theme
- Is there a get_post(s) filter that can alter/replace the output completely?
- add_filter does not work as expected
- Filter taxonomy admin pagination
- Custom view counts not updating correctly
- Using wp_handle_upload() to Direct Specific Path by Using $overrides
- Separeting product from post in search result
- Search and Filter
- Filter the_posts doesn’t work on search page
- Formatting get_post content doesn’t allow JS content to function properly
- Proper after_setup_theme and wp_head cleanup
- Why doesn’t remove_action work in my plugin?
- Upload restrictions – upload_mimes – filter: Adding multiple MIMEs for a single extension and adding multiple extensions for a single MIME type?
- How can I change the email that is inside the default email texts of wordpress?
- Modify message displayed on post save
- Something is filtering my shortcodes… Can’t figure out what
- Pass debug_backtrace() in WordPress filter
- Post filtering is returning blank page
- Remove actions/filters that are set with create_function()
- I need to hook and change language of facebook sdk
- change “missing attachment” text functions.php
- Use has_filter on comment_post
- return get_the_tag_list with whitespace removed
- How do I add tags to entire comments, not just their text
- Modify author url display in edit-comments.php
- add_filter( ‘the_title’ gets through this if statement twice
- Changing the category for existing Gutenberg blocks
- Filter Post Title without affecting screen-reader-text
- Modify WordPress Page Title ()
- How to add lazy field in content endpoint using Gutenberg blocks
- how to use apply filter for Class?
- How can I see exactly what arguments are being passed through a filter so that I may modify them?
- Widget image reorganize layout
- Set Microsoft Word links to open in new window/tab
- WordPress get_avatar filter to match logins
- Modify category listing API response
- Change shortcode output (filter?)
- How do I add a class to all sidebars to let a Google Custom Search Engine know not to index the content?
- How to replace all images in all posts and pages with a different size?
- How to add a class to Buddypress avatars in the Activity stream? [closed]
- Updating User Profile on Registration
- ACF Load Field Groups Programmatically [closed]
- Why does using excerpt_more filter change link location?