这个Codex link 已经有你想要的东西了。也许你只是不知道如何使用参数。。。
我会通过date_query
:
$args = array(
\'post_type\' => \'post\',
\'post_status\' => array(
\'publish\',
\'future\',
),
\'date_query\' => array(
array(
\'after\' => strtotime( \'now\' ),
\'before\' => strtotime( \'+1 month\' ),
),
),
\'posts_per_page\' => -1, // or a high number, if you want to pre-fetch post meta data
);
$query = new WP_Query( $args );
while ( $query->have_posts() ) {
$query->the_post();
// now you can use the_title(), the_content() etc.
}
wp_reset_postdata();
// EDIT:
如果只想显示(整个)下个月的帖子,可以尝试以下日期查询:
$date = strtotime( \'+1 month\' );
$args = array(
\'post_type\' => \'post\',
\'post_status\' => array(
\'publish\',
\'future\',
),
\'date_query\' => array(
array(
\'year\' => date( \'Y\', $date ),
\'month\' => date( \'n\', $date ),
),
),
\'posts_per_page\' => -1, // or a high number, if you want to pre-fetch post meta data
);