從 WordPress3.7 開始,加了一個 api  date_query

這樣,為得到最新的 post(文章) 或評論提供了方便。

程式碼如:

----------------

<?php
    $popular = new WP_Query( array(
        'post_type'             => array( 'post' ),
        'showposts'             => 6,
        'cat'                   => 'MyCategory',
        'ignore_sticky_posts'   => true,
        'orderby'               => 'comment_count', //--這個意思就是 取得評論數最多的文章
        'order'                 => 'dsc',
        'date_query' => array(
            array(
                'after' => '1 week ago', //近期一週的,這個是本檔案的重點
            ),
        ),
    ) );
?>
<?php while ( $popular->have_posts() ): $popular->the_post(); ?>
    <?php the_title(); ?>
<?php endwhile; ?>

------------------------------

http://www.viper007bond.com/2013/08/27/date-queries-in-WordPress-3-point-7/