Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/287.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php WP_查询按大多数匹配值排序(不包括ACS部分和DESC其他)_Php_Wordpress - Fatal编程技术网

Php WP_查询按大多数匹配值排序(不包括ACS部分和DESC其他)

Php WP_查询按大多数匹配值排序(不包括ACS部分和DESC其他),php,wordpress,Php,Wordpress,我有下面的示例查询,其中结果首先基于位置返回,通常可以使用meta_查询进行更多过滤 问题是,我不完全确定如何根据匹配All/Most的个体对结果进行排序,然后是匹配Less的个体,最后是匹配Less 为了澄清meta_查询,1个值的权重并不大于另一个值 $args = array( 'update_post_term_cache' => false, 'post_type' => 'vandelay_industrie

我有下面的示例查询,其中结果首先基于位置返回,通常可以使用
meta_查询
进行更多过滤

问题是,我不完全确定如何根据匹配
All/Most
的个体对结果进行排序,然后是匹配
Less
的个体,最后是匹配
Less

为了澄清
meta_查询
,1个值的权重并不大于另一个值

$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'
                ),
            )
        );

我不是一个超级sql专家,也许我错了,但OR子句将在满足任何条件时返回结果。所以,如果头发类型像$value,返回结果,其他条件将不会被检查。所以我不认为可以按大多数匹配值排序,因为一旦得到1个匹配项,就会返回结果。我将对您的问题进行投票,然后再进行讨论,因为它非常有趣,希望一些SQL专家能够看到它并给出可靠的答案answer@AngelDeykov这是一个极好的观点。我将很快进行细化,以包括AND或2的组合,以进行澄清。