Wordpress 自定义分类法的税务查询未按预期工作

Wordpress 自定义分类法的税务查询未按预期工作,wordpress,Wordpress,我希望有人能帮我找出问题所在。我有一个名为events_cat的自定义分类法,我正在尝试显示分类法术语11中的所有post类型事件,但是下面的代码正在引入不在该分类法术语中的事件,我看不到错误。你知道是什么导致了这个问题吗 <?php $args = array( 'post_type' => 'event', 'posts_per_page' => -1, 'tax_query

我希望有人能帮我找出问题所在。我有一个名为events_cat的自定义分类法,我正在尝试显示分类法术语11中的所有post类型事件,但是下面的代码正在引入不在该分类法术语中的事件,我看不到错误。你知道是什么导致了这个问题吗

<?php 
    $args = array(
            'post_type'        => 'event',
            'posts_per_page'   => -1,
            'tax_query'        => array(
                                   'relation' => 'AND',
                                   array(
                                        'taxonomy' => 'events_cat',
                                        'field'    => 'term_id',
                                        'terms'    => array(11),
                                    ),
            ));
    $upcomingEvents = new WP_Query($args); ?>

谢谢你的帮助。它应该会起作用,但没有解决问题。我现在发现模板的function.php文件中有一个函数覆盖了查询,这就是为什么它不能按预期工作的原因?请分享你的完整代码。
$custom_args=array(
              'post_type'   => "event",
              'post_status'     => 'publish',
              'posts_per_page'  => -1, 
              'caller_get_posts'=> -1,
              'hierarchical'    => 1,
              'exclude'         => '',
              'include'         => '',
              'number'          => '',
              'tax_query'       => array(
                                        array(
                                            'taxonomy' => 'events_cat',
                                            'field' => 'id',
                                            'terms' =>"11"
                                        )
                                    ),
             'orderby'          => 'id',
             'order'            => 'ASC'
            );
            $custom_my_query = null;
            $custom_my_query = new WP_Query($custom_args);
            $custom_my_total_count = count($custom_my_query);
            if( $custom_my_query->have_posts() ) 
            {
                    while ($custom_my_query->have_posts()) : $custom_my_query->the_post(); 
                        ?>
                        <a href="<?php echo get_permalink();?>"><?php echo get_the_title($post->ID);?></a>
                        <?php
                      endwhile;
            }
            wp_reset_query($custom_my_query);  // Restore global post data stomped by the_post().
    }