• Hi, I would like to modify current orderby for multiple terms, being able to order my posts by relevance and post_date. I’ve seen some hook filters, but didn’t work for multiple.

    I’m able to adjust the “orderby” just for one of them manually through the hook, but not for multiple.

Viewing 1 replies (of 1 total)
  • Plugin Author Mikko Saari

    (@msaari)

    add_filter( 'relevanssi_modify_wp_query', 'rlv_set_orderby' );
    function rlv_set_orderby( $query ) {
        $query->set( 'orderby', array(
            'relevance' => 'desc',
            'post_date' => 'desc',
        ));
        return $query;
    }

    Multiple orderby is just an array of ‘orderby’ => ‘order’ pairs. Relevanssi will use them in the order you give them, sorting by the first one first and if that gets a tie, then moving on to second and so on.

Viewing 1 replies (of 1 total)
  • The topic ‘Multiple orderby on query’ is closed to new replies.