this might work:
this section would go into functions.php of your theme:
// Create a new filtering function that will add our where clause to the query
function filter_where_next_week( $where = '' ) {
// scheduled posts for next 7 days
$where .= " OR post_type='post' AND post_date > '" . date('Y-m-d') . "' AND post_date <= '" . date('Y-m-d', strtotime('+7 days')) . "'";
return $where;
}
this part would go into a template:
<?php add_filter( 'posts_where', 'filter_where_next_week' );
$query = new WP_Query( $query_string . '&post_status=future' );
if( $query->have_posts() ) :
while( $query->have_posts() ) :
$query->the_post();
the_title();
the_date();
endwhile;
else : echo 'nothing scheduled in next week';
endif; wp_reset_postdata();
remove_filter( 'posts_where', 'filter_where' );
?>
not widely tested.
http://codex.wordpress.org/Class_Reference/WP_Query#Time_Parameters
Wow that was fast! And the best part: it works! Thanks alchymyth! Thanks so much!
one more thing 🙂 is there a chance to output the number of results from this query? if 5 posts are found > 5 / if 3 are found > 3 / and so on?
do you mean you want to show all posts that are is found?
try:
$query = new WP_Query( $query_string . '&post_status=future&posts_per_page=-1' );
no, only to the number of posts that are found.
eg. we have found 8 posts for the within the next 7 days.
no, only to the number of posts that are found.
yes, that what the posts_per_page=-1
is for; -1
means: show all that are found.
I haven’t tested my latest suggestion – have you tried it?
sorry, actually i just want the NUMBER of posts to be display, not the content of those posts.
now I am getting it now ;-(
try:
$query = new WP_Query( $query_string . '&post_status=future&post_per_page=-1' );
echo 'fp'.$query->found_posts;