WP_Query sort by MOST matching values ( not ACS some and DESC others )

Viewed 79

I have the following example query, where results are returned based on location first and can be filtered normally even more with a meta_query.

The issue is, I'm not entirely sure how to order the results based on individuals matching All/Most to people who match Less and then the Least at the end.

To clarify on the meta_query, 1 value isn't weighted more than the other.

$args = array(
            'update_post_term_cache' => false,
            'post_type'         => 'vandelay_industries',
            'posts_per_page'    => $request['per_page'],
            'paged'             => $request['page'],
            'geo_query' => array(
                'lat_field' => 'flat_lat',  // this is the name of the meta field storing latitude
                'lng_field' => 'flat_lng', // this is the name of the meta field storing longitude 
                'latitude'  => $lat1,    // this is the latitude of the point we are getting distance from
                'longitude' => $lng1,   // this is the longitude of the point we are getting distance from
                'distance'  => $proximity,    // this is the maximum distance to search
                'units'     => 'miles'       // this supports options: miles, mi, kilometers, km
            ),
            'meta_query' => array(
                'relation' => 'OR',
                array(
                    'key' => 'hair_types',
                    'value' => $value1,
                    'compare' => 'LIKE'
                ),
                array(
                    'key' => 'education_type',
                    'value' => $value2,
                    'compare' => 'IN'
                ),
                array(
                    'key' => 'something_else',
                    'value' => $value3,
                    'compare' => 'LIKE'
                ),
                array(
                    'key' => 'george_is_getting_upset',
                    'value' => $value4,
                    'compare' => 'IN'
                ),
            )
        );
0 Answers
Related