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
- posts_results filter – additional sort, with a meta value, to move posts to the end of the results, with pagination working
- Is it possible to modify a WP search query to return results for private pages when not logged in?
- How to add defer=”defer” tag in plugin javascripts?
- How do filters and hooks really work in PHP
- Trouble understanding apply_filters()
- How would one modify the filtering Gutenberg applies to pasted content?
- Gutenberg: Is there a way to know if current block is inside InnerBlocks?
- WordPress Internal @ Mentions
- Is it possible to use object in add_action?
- Add Class to Specific Paragraph of the_content()
- apply_filters() slices away needed arguments
- How to override the email function by using filters? [closed]
- Remove WPML’s home_url filter
- Edit pagination text in the get_the_posts_pagination function
- How does WordPress call functions attached to a certain action hook before calling functions attached to other hooks
- How to get current action?
- how to change appearence of the content of default post list columns?
- Allow EPS file upload – two EPS files have different MIME types
- How to call a function or method that is Namespaced using another plugin
- How to change currency programmatically on creating order action?
- Change username before login
- apply_filters(‘the_content’) – make it ignore shortcodes?
- Replace a word with a word in the URL string
- Remove Actions added by SEO ultimate Plugin
- Modifying a CoBlocks Filter in Functions
- Remove Content Filter
- Building a request processor for multi-page forms, etc using $_GET requests
- how to use force_filtered_html_on_import in add_filter?
- Filter Hook callback error, is it due to using $this inside a filter or something else?
- Disadvantage of using filters & hooks multiple times
- How To Override A WooCommerce AJAX Function
- run shortcode in excerpt of single custom post type
- Get The Caller (Plugin / Theme / Core) For All actions & Hook in WordPress
- Stripping URLs & Email from post submissions
- comment_for() Custom fields not visible when user is logged in
- I’ve set up an extra field for all the available widgets. How do I show it’s value in the front-end?
- Remove pretty photo style and script if not exist!
- How to Add Additional Search Button?
- Add Filter to Ignore a Post/Page or a Number of Post/Pages
- BuddyPress – A hook available to hide custom born date on public profile view?
- the_content getting current page content instead specified ID
- Override wordpress audio playlist
- Hook to add content after date in post?
- Add Index to Item in WordPress Gallery
- How to add_filter only when content is not empty?
- filter out
- How do i search post by jquery datepicker?
- Filter template text
- WP Dashboard -> Posts-> Filter > BUG!
- How do I disable the warning “The backup of this post in your browser is different from the version below”?
- How to get to the date of the uploaded file
- How to filter posts in admin by before date or by post status ‘future’?
- Can’t get content of all (19) posts – Incomplete Chunked Encoding
- WooCommerce comments_template Filter Not Firing
- Woocommerce: Only one review per verified buyer [closed]
- Footnotes with dynamic title attributes?
- Can you call a filter hook by “add_action”?
- Filter widget_pages_args not working in Pages Widget
- Load More : Admin Ajax 400 Bad request, returning 0
- How to add placeholder into comment form textarea?