Posts for next month

The Codex link already has anything you seem to be after. Maybe you just didn’t know how to use the parameters…

I would do this by means of a 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:
If you want to display posts from the (whole) next month only, then you might try the following date query:

$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
);

Leave a Comment