relevanssi_comparison_order

apply_filters( 'relevanssi_comparison_order', array $order )

Provides a sorting order for custom sorting.

Parameters

$order
(array) An array of key values as keys and their sorting order as values.

More information

If you specify post_type as the sorting key, Relevanssi will use this filter hook to get the sorting order. You can also use the filter hook relevanssi_sort_compare to specify the compare method of filter to use this sorting for other keys.

If you want for example post type post first in the result, then post type page and finally the post type news last, you can do:

add_filter( 'relevanssi_comparison_order', 'rlv_post_type_order' );
function rlv_post_type_order( $order ) {
  $order = array(
    'post' => 0,
    'page' => 1,
    'news' => 2,
  );
  return $order;
};

Now when you specify orderby=post_type, Relevanssi will use this order to sort the posts.

add_filter( 'relevanssi_modify_wp_query', 'rlv_orderby' );
function rlv_orderby( $query ) {
    $query->set( 'orderby', 'post_type' );
    return $query;
}

Any values that don’t have a specified sorting order in the array are sorted last in the results.