WP_Query 存档页面日期无效

WP_Query for Archive Page Date not work

我已经在 archive.php 上编辑了我的主题,以便仅显示特定的 post 并排除具有特定 meta_key:

的 post
$posts_to_exclude_args = array(
                    'meta_key' => 'vip_box',                
                    );
                    $posts_to_exclude = new WP_Query( $posts_to_exclude_args );
                    $to_exclude = array();
                    while ( $posts_to_exclude->have_posts() ) : $posts_to_exclude->the_post(); 
                        $to_exclude[] = $post->ID;
                    endwhile;
                    wp_reset_postdata();
                    $lastupdated_args = array(
                    'post__not_in' => $to_exclude,
                    'author__in'     => $author,
                    'category__in'   => $terms,
                    'posts_per_page' => 12,
                    'has_archive' => true,
                    'paged'          => $paged,                 
                    );
                    $lastupdated_loop = new WP_Query( $lastupdated_args );
                    query_posts( $lastupdated_args );
<?php if ( have_posts() ) : ?>

非常完美,但现在如果我打开一个日期 link/url 我的网站。com/2017/06 它会显示所有 post 而不仅仅是 post 这个日期,为什么?

你能帮帮我吗?

我已经修复了这段代码,但我认为还有比这更好的解决方案。 =)

$year     = get_query_var('year');
                    $monthnum = get_query_var('monthnum');
                    $day      = get_query_var('day');

'date_query' => array(
                        array(
                        'year'     => $year,
                        'monthnum'    => $monthnum,  
                        'day'  => $day,  
                            ),
                        ),
                    );