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
- Why wordpress doesn’t allow to add author filter to media library page in grid mode
- Is it possible to modify a WP search query to return results for private pages when not logged in?
- This code works, but breaks the media uploader. How do I integrate it in a way that won’t?
- Replacing text using add_filter
- Using two posts_orderby add_filter makes conflict
- Background color and background image below element in Contact Form 7 – error tip [closed]
- Query Multiple Filters, one with Meta
- How to remove a filter that is an object method?
- Passing value from one hook to another
- Deregister Custom the_title Filter for edit_post_link
- custom post filter based on Visitors country
- Filter a custom post type by custom field in admin
- How to correctly override a filter?
- Limit total tags in the_content
- Is there a way to check if the ‘wp_sitemaps_enabled’ is true or false?
- How to use filter in this situation, can not modify the structure using filter
- Block Gutenberg Editor manually by User Roles with a Filter with code
- Is it possible to dynamically change the “page_for_posts” option?
- Change password reqts with NO plugin without breaking resetpass link?
- Using the REST API filter, including two meta_queries breaks the response for one custom post type
- How can I conditionally add the filter option_home?
- Adding filter to the Contact Form 7 response
- Remove rel=”ugc” from links in comments
- How to use parse_query() to add an additional filter based on content to page search?
- FacetWP was unable to auto-detect the post listing : Having an issue with ACF load choices causing FacetWP error
- How to change content hash value, within the_block_template_skip_link action?
- add_filter – create_function pb in PHP8
- How to apply_filter / add_filter within 2 others (simultaneous?) add_filter
- How to Dynamically Switch WordPress Front Page Without Causing Canonical Redirect?
- Change or replace user_profile_picture_description filter, to stop stripping whitespace
- Woocommerce price filter widget always shows max price of most expensive product in the whole shop
- remove_function method removing next priority action too while removing current priority
- Are blocks that are converted to patterns no longer filterable through the_content?
- How to use add_filter to add the extra data to existing array?
- wc_get_template_part filter not working
- hook on the_excerpt
- Deactivate code made with add_filter
- ‘Problem’ with login_redirect filter – why does it lose the redirect_to parameter
- Is there a way to override only a portion of the function print_media_templates defined in wp-includes\media-template.php?
- How could I create real-time filtering in this case?
- How to filter products by category in custom loop
- How to use render_block filter in Gutenberg when editing a page?
- WordPress REST API and Backbone JS
- “Invalid parameter(s): attributes” issue in context of “blocks.registerBlockType” filter
- How can I change the post order after filtering in WordPress?
- How do I query Pending posts?
- How to override hook from themes functions.php which is defined in plugin
- How to increase comment length?
- Load More : Admin Ajax 400 Bad request, returning 0
- wp reset password page – head inline script
- add_filter( ‘user_has_cap’,’my_function’, 10, 3 ); and call to get_users in my function triggers an infinite loop in user list
- Custom updater to change plugin version
- Adding custom filter not working
- Core/Image access caption in render_template and in wp.hooks
- Ship block templates or block template parts with plugins
- How to add custom field to top of WordPress Comment Form for both logged in and anon users
- Filter hook for the action of listing users
- AAPF Filter group is not in widget section
- How can I inject an SVG gradient into the site/theme editor’s head or footer?