Php WP#u查询以使用';或';

Php WP#u查询以使用';或';,php,wordpress,Php,Wordpress,我想得到两种不同分类法的帖子 我只想列出那些带有标签longform或post\u格式为typelink的帖子 我尝试了以下代码,但不起作用: $query = new WP_Query(array( 'relation' => 'OR', 'posts_per_page' => 2, array( 'taxonomy' => 'post_format', 'field' => 'slug', 'ter

我想得到两种不同分类法的帖子

我只想列出那些带有标签
longform
post\u格式
为type
link
的帖子

我尝试了以下代码,但不起作用:

$query = new WP_Query(array(
   'relation' => 'OR',
    'posts_per_page' => 2,
    array(
        'taxonomy' => 'post_format',
        'field' => 'slug',
        'terms' => array( 'link' ) // Single terms as string - multiple as array
    ),
    array(
        'taxonomy' => 'Tag',
        'field' => 'id',
       'tag__in' => array('16') // 16 is the code for tag longform
    )
));

这应该管用

你能用我在问题中提到的确切id和slug编辑你的答案吗,因为我对你的答案有一些混淆。@Hussain它不起作用,实际上我在function.php文件中做了一个短代码来列出帖子,不知道错误在哪里,如果我只设置了一个条件,就像
'tag'=>'longform'
一样,那么它就可以工作了。
$terms = array('link');
$tax = array(16)

 $args = array( 
                           'post_type' => 'post',
                           'tax_query' => array(
                            'relation' => 'OR',
                                    array(
                                        'taxonomy' => 'post_format',
                                        'field'    => 'slug',
                                        'terms'    => $terms,
                                    ),
                                    array(
                                        'taxonomy' => 'space',
                                        'field'    => 'id',
                                        'tag__in'    => $tax,
                                    ),
                            ),
                           'posts_per_page' => 2
                        );


                    $the_query = new WP_Query( $args );