获取 post 类型和类别

Get post type and category

在我的首页 (index.php) 我想显示类型 'event' 的所有 post 以及类型 [=] 的类别 'main' 16=]。我怎样才能合并这两个条件?在我当前的代码中,我可以过滤两个 post 类型但不能过滤类别 'main'.

<?php global $wp_query; $args = array_merge( $wp_query->query, array( 'post_type' => array('post','event') ));
query_posts( $args ); ?>

只需将 $args 更改为:

<?php
$args = array(
    'post_type' => array('post','event'),

    'tax_query' => array(
          'relation' => 'OR',
       array(
         'taxonomy' => 'category',
         'terms' => 'main',
         'field' => 'slug'
       ),
       array(
         'taxonomy' => 'event_tag', // this needs to be whatever custom taxonomy you have declared for your custom post type.
         'terms' => 'main',
         'field' => 'slug'
       ),
    )
);
?>