문제

I have a simple WP_query on a custom post and works fine:

$args = array(
  'post_type' => 'post-type',
  'showposts' => 2,
  'location' => 'london'
);

but I want it to query two locations so used an array:

$args = array(
  'post_type' => 'post-type',
  'showposts' => 2,
  'location' => array('london','paris')
);

but it only pulls in the last term. Is there another way that I should be doing this?

도움이 되었습니까?

해결책

$args = array(
    'post_type' => 'post-type',
    'tax_query' => array(
        array(
            'taxonomy' => 'location',
            'field' => 'slug',
            'terms' => array('london','paris')
        )
    )
);

Try this

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top