Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/three.js/2.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
Wordpress WP_在单个分类法上查询两次_Wordpress_Custom Post Type_Taxonomy - Fatal编程技术网

Wordpress WP_在单个分类法上查询两次

Wordpress WP_在单个分类法上查询两次,wordpress,custom-post-type,taxonomy,Wordpress,Custom Post Type,Taxonomy,我对自定义帖子有一个简单的WP_查询,效果很好: $args = array( 'post_type' => 'post-type', 'showposts' => 2, 'location' => 'london' ); 但我想让它查询两个位置,因此使用了一个数组: $args = array( 'post_type' => 'post-type', 'showposts' => 2, 'location' => array('lo

我对自定义帖子有一个简单的WP_查询,效果很好:

$args = array(
  'post_type' => 'post-type',
  'showposts' => 2,
  'location' => 'london'
);
但我想让它查询两个位置,因此使用了一个数组:

$args = array(
  'post_type' => 'post-type',
  'showposts' => 2,
  'location' => array('london','paris')
);
但它只在最后一个学期才开始。我还有别的办法吗

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