Wordpress WP_Query where clause with OR?

前端 未结 4 497
梦谈多话
梦谈多话 2020-12-21 09:02

hello friends this is my args for WP_Query.

$args = array(\'post_type\' => \'job_listing\');
$args[\'meta_query\']=array(
   \'relation\' => \'OR\',
           


        
4条回答
  •  误落风尘
    2020-12-21 09:41

    For the OR Query argument array should be like this:

    $args = array(
        'post_type' => 'post',
        'meta_query' => array(
            'relation' => 'OR',
            array(
                'key' => 'app_trailer-type',
                'value' => $job_tailor,
                'compare' => 'LIKE'
            ),
            array(
                'key' => 'app_pay-type',
                'value' => $app_pay_type,
                'compare' => 'LIKE'
            ),
            array(
                'key' => 'geo_address',
                'value' => $geo_address,
                'compare' => 'LIKE'
            ),
            array(
                'key' => 'geo_country',
                'value' => $geo_country,
                'compare' => 'LIKE'
            ),
            array(
                'key' => 'geo_short_address',
                'value' => $geo_short_address,
                'compare' => 'LIKE'
            ),
        )
    );
    

    Reference: http://codex.wordpress.org/Class_Reference/WP_Query

提交回复
热议问题