jacall.net
前端开发工作者
© JaCall.Net
All Rights Reserved.
皖ICP备13004974号-1

query_posts某段时间内的文章

<?php // 获取从2013年10月2日 到 2013年12月2日,且发布天数在2-22日之间的所有文章
$query_posts = query_posts(
    array(
        'date_query' => array(
            array(
                'after'     => array( // 从2013年10月2日开始
                    'year'  => 2013,
                    'month' => 10,
                    'day'   => 2,
                ),
                'before'    => array( // 到2013年12月2日结束
                    'year'  => 2013,
                    'month' => 12,
                    'day'   => 2,
                ),
                'inclusive' => true,
            ),
            array( // 天数 >= 2
                'day'      => 2,
                'compare'   => '>=',
            ),
            array( // 天数 <= 22
                'day'      => 22,
                'compare'   => '<=',
            ),
        ),
        'posts_per_page' => -1,
    )
);
?>
<?php if (have_posts()) : while (have_posts()) : the_post();?>
<p><?php the_time("Y-m-d")?><br /><?php the_title();?></p>
<?php endwhile; endif;?>

 

2013-10-17
3,874 views
关键字:
暂无评论

发表回复