如何始终首先从搜索结果中显示特定帖子

I created a search filter that displays posts randomly, and I wonder how can I always display a specific post item in the first position of the search results and display the rest of the items normally.

Thank you for your help @dassoun, here is the query :

$taxonomies = array('recipe_type', 'product_category', 'recipe_category', 'recipe_event', 'recipe_diet');
foreach ($taxonomies as $taxonomy) {
    $taxonomies_taxonomy[$taxonomy] = get_taxonomy($taxonomy);
    $taxonomies_terms[$taxonomy] = get_terms(
        array(
        'taxonomy'      => $taxonomy,
        'hide_empty'    => false,
        'meta_key'      => 'filter_order',
        'orderby'       => 'meta_value_num',
        'order'         => 'ASC'
        )
    );
    $taxonomies_selected[$taxonomy] = (get_query_var($taxonomy)) ? get_query_var($taxonomy) : '';
}

I think you should have a look at the "UNION" operator.

from https://www.w3schools.com/sql/sql_union.asp: The UNION operator is used to combine the result-set of two or more SELECT statements.

  • Each SELECT statement within UNION must have the same number of columns
  • The columns must also have similar data types
  • The columns in each SELECT statement must also be in the same order

The idea would be:

select * from post where (hastobetop = 1 or id = myid or whatever)
UNION
yourfilteredrequest

You may have to exlude the rows returned by the first request from the filtered one.

[edit] Sorry, I hadn't seen it was specific to wordpress [/edit]