It is not the most elegant solution, but you could sort the results on your search page:
At the top of your page, make the wp_query variable available
global $wp_query;
Later in you code, if there are some results :
if ( have_posts() ) {
//your desired order
$order = array(45, 78, 94);
// a comparison function to sort the post array with your custom one
function sortByIds($a, $b){
global $order;
$a = array_search($a->ID, $order);
$b = array_search($b->ID, $order);
return $a - $b;
}
//we use usort to sort the wp_query post using a comparison function
// note, we could use a closure if your php version supports it
usort($wp_query->posts,'sortByIds');
//then your normal code....
}
It is not an sql solution but it works.
Related Posts:
- Rewrite URL custom search query
- Highlighting Sub topic in a post?
- Multiple keyword search
- How do I search inside specific taxonomies in WordPress
- How to find exact match for search term in WP_Query? What is the additional string added in LIKE query in WP_Query?
- Creating a custom search for a specific post type
- How to loop for every result found in the_content() when using the search query?
- Is there any advantage of using default WordPress Search instead of creating a custom one?
- Editing the default wordpress search
- Cutom wp_query for geolocation search, pagination not working
- Include data from custom table in WP_Query
- Modify Search Query if original Query gave no results
- Get a list of posts by specific category
- Get specific ACF key and value from all posts – no access to DB
- Prioritising and Ordering Posts By Category Name Using A Custom Loop
- How to extend WP_query to a specific table?
- Display the search results like the original pages
- Search has query that will return no results
- WP Query – Search in title or author_name
- How to show terms from another taxonomy
- How can I modify standard search query to include also ACF custom fields values?
- Search Functionality broken by the wp 4.2 update
- Need help setting up a search form for wordpress [duplicate]
- Search query alteration not working for meta values
- Search results stuck on page 1
- Advanced Search – Is this possible?
- Modify WordPress Search
- $wp_query->found_posts; returns zero
- Query with relation and one without relation using multiple taxonomies?
- WP Query to have sticky posts first, with pagination and having a joint ‘posts per page’ arg with main loop
- How to make search for posts using get method?
- No results found from a $wpdb->get_results() query when trying to join more than one meta key query
- Meta Query relation “AND” then set array accordingly
- Categorising search results based on Custom Fields
- How to get a query variable?
- How to get list of posts from permalinks?
- echo a specific meta_key queried through a custom post
- date_query seems to be ignored by wp_query
- Is there a reason why Pages are not publicly_queryable?
- Query Page Content From Theme Options?
- WP Group posts by year(desc) > month(desc) > date(asc)
- How can I allow sticky posts but cap the query to 1 post?
- WooCommerce search products between price range using WP_Query
- Add filter post_where and passing post_type argument
- Check return value of get_posts
- Better wordpress attachment query than this
- Exclude some authors from query
- using pre_get_posts for search results not found
- Sort WordPress Posts Meta value by Week not Day
- Search posts missing a particular custom field
- How do I get my custom query to work with search results after the first page?
- Query only the posts with a post format of “audio”
- Is_single() conditional tag returns null in query
- 2 wordpress loops showing 1 post from same post type – how to avoid showing the same post?
- Transient api Caches confused
- How can I override one post and make it display content for another post?
- Include current post into loop
- Exclude posts with specific metadata from search?
- Is it possible to query from external database? [duplicate]
- Custom Loop Query For Search Page
- Can’t sort custom post type by random
- Include post content of linked posts in search
- pre_get_posts – Trying to get property of non-object warning
- Replacing search results with custom external query
- Prevent author bio page from showing in search results
- Query posts that contain video?
- Get multiple users with meta value in one query and populate WP_User class
- WordPress query posts with multiple post_meta data
- How do I amend wp_query before it is run/executed?
- wp_query search not taking keywords with together for multiple words
- Filter post query to only show direct children of category
- Wildcard search in WP Query
- Show a 404 error page if Public query variable’s value doesn’t exist?
- WordPress Custom Search Form Displaying Unexpected Results
- How to check the array values, what WP_Query has brought to me?
- Search Page Returns Nothing
- How to set up hierarchical relationships without using plugins / meta query
- How to add custom meta to ‘pre_get_terms’?
- Set front_page programatically after user login via query, while leaving site option alone
- Redirect Search to Form When No Product Results Are Found
- How to properly use AND / OR in custom search
- Shortcode for custom query not returning results when attributes are added
- Should I reset $wp_query?
- How to avoid bypass of search bar rules?
- Yoast primary category query modification
- Hide products in uncategorized category from search results
- Query where ANDing slug values not working
- How to order posts on each different category?
- Issues with search after added meta_query
- How to filter query loop block with a search string from the query parameters
- Update query for wp_posts and wp_postmeta
- How do you determine if a result in a search query is a post or a page?
- Slow Query On Search
- Sorting search results with custom dropdown
- How To Keep Search Title the same on paged Results
- How to remove only the latest sticky post from the loop
- wp_query show all values
- change posts_orderby of the callback wp_query?
- How to search for meta_query LIKE or tax_query LIKE and grab these posts on search results?
- mysql query order by