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:
- 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?
- order by numeric value for meta value
- numberposts? showposts? posts_per_page?
- WP_Comment_Query pagination, delving into the unknown
- Sort posts by category name and title
- wp_query for the first sticky, then display the rest of the posts excluding the first sticky
- Pagination wont work with search results template [duplicate]
- Pagination Not working on Home Page with 2 Query
- how to retrieve specific product attribute value in an sql query?
- WordPress custom archive page
- Retrieve or Query Pages by ID
- Include Sticky Posts in Page Post Count for custom query
- Query sticky posts with thumbnails
- Searching through different categories on different pages code is not working
- How to implement time filter to show random post 1 month for one category and 3 months for other categories
- WP_Query’s “request” SQL Query
- How to do a query on custom taxonomies that is uncategorised?
- is_search was called incorrectly
- Empty tax_query array returns an empty array
- How to correctly pass values to wpdb->prepare()?
- Complex date range with WP_Query and BETWEEN
- Setting get_queried_object
- remove query arg from url after set query
- difference between like ‘%%%var%%’ and ‘%var%’
- Order By table field comment_status in WordPress > 4.0
- wp_query should show stickies first
- Sort query by author: 1 author, then others
- Overwrite YoastSEO meta-tags with another page’s [closed]
- How to orderby multiple meta fields if some fields are empty
- Multiple Search Terms WP_Query
- How to duplicate 5 posts out of WP_Query results?
- WP Query Args – Title or Taxonomy Value
- WP_query sorting can’t sort danish letters (æ, ø, å)
- Slow queries on a huge database
- wordpress search word, “hello world” ===> ‘hello+world’ ===> ‘hello’, ‘world’
- Multisite pagination issue by multi query archive 404
- Query with relation and one without relation using multiple taxonomies?
- Categorising search results based on Custom Fields
- using pre_get_posts for search results not found
- Transient api Caches confused
- How can I override one post and make it display content for another post?
- Get multiple users with meta value in one query and populate WP_User class
- Redirect Search to Form When No Product Results Are Found
- Issues with search after added meta_query
- How to search for meta_query LIKE or tax_query LIKE and grab these posts on search results?
- How to filter a static post page with ajax and $wp_query
- Magazine style frontpage with multiple categories/loops and no duplicate posts
- Is there a (preferable built-in) way to check what custom queries are used in a theme?
- $wp_query->found_posts not returning correct value
- Post incorrectly excluded when using “category__in”?
- How to search by slug and old slug in single API
- Display posts ONLY from the current logged in user and current week/year/month Elementor posts
- Pagination repeating posts on search results
- Any way to use FETCH_KEY_PAIR with $wpdb?
- Categories In English version showing not canonical URL, instead shows query search result
- How to use wp query in my custom page without including header and footer in wordpress
- Filter admin ajax data by url query
- Query against multiple locations within single custom post type post
- How to debug none working search query?
- WP Query. Ordering posts by another post types meta
- WP_Query about meta_key and its array value
- Create global array to compare inside a query
- Search Field that allows options of “Match any keyword” or “Match all keywords”
- A very strange problem with search query
- Filter posts/pages by user_role array
- Search Query that Includes Custom Table
- Custom post types loop on a page template
- WP_Query breaks pagination
- Parsing External Table Arguments
- difference between methods of query
- Pagination problem with multiple loops on the same page
- Query posts by meta value and sort by another meta key
- how to use transient method?
- Why does WP_Query not search for two ‘meta_query’ keys separated with OR?
- WordPress WP_Query Search (‘s’) With Multiple Search Terms
- Use value from meta key array for use in WP_Query