Apart from posts and pages there are profiles on my site. Does exist some way how could I push them to the top of the search results? Currently, results are ordered at first by keyword and then by date. Problem is, the posts (about persons; e.g. announcements) are almost always newer than profiles. It is logical: profile was added only once, posts are posted continuously. So profile may be in the top 10, but also not. If there exists ten newer posts about person whose name is searched, person’s profile will be too deep in the list (common case). It is wrong. If I search the person’s name, profile is always the most relevant content, so it always should be the first result.

2 s
Since WP 3.7 there is a filter "posts_search_orderby"
that allow to set the ordering for search.
To be sure that filter works as expected set "orderby"
to "relevance"
.
add_action( 'pre_get_posts', function( $query ) {
if ( $query->is_search() ) {
$query->set( 'orderby', 'relevance' );
}
} );
and then, assuming your profiles CPT slug is “”profiles”:
add_filter( 'posts_search_orderby', function( $search_orderby ) {
global $wpdb;
return "{$wpdb->posts}.post_type LIKE 'profiles' DESC, {$search_orderby}";
});
In this way as usually, will be shown all posts that have the searched keywords in post title or post content, but ordering in this way:
- posts with profiles CPT, no matter if searched keywords are in title or in content, ordered by descending date
- posts with searched keywords in title, no matter post type, ordered by descending date
- posts with searched keywords in content, no matter post type, ordered by descending date