http://codex.wordpress.org/Class_Reference/WP_Query#Time_Parameters
<?php $today = getdate();
$this_month = new WP_Query( array( 'posts_per_page' => -1, 'year' => $today["year"], 'monthnum' => $today["mon"]) );
if( $this_month->have_posts() ) : while( $this_month->have_posts() ) : $this_month->the_post();
/*whatever you want to output*/
endwhile;
else : echo 'no posts this month';
endif; wp_reset_postdata(); ?>
http://codex.wordpress.org/Class_Reference/WP_Query#Time_Parameters
ok its kinda worked.
If there isn’t a post for that month it comes up with ‘no posts this month’ but when there is a post for the month it just comes up blank… what am I missing?
what coding have you put instead of this spaceholder:
/*whatever you want to output*/
well went on to the link you posted and put in the code
// Create a new filtering function that will add our where clause to the query
function filter_where( $where = '' ) {
// posts in the last 30 days
$where .= " AND post_date > '" . date('Y-m-d', strtotime('-30 days')) . "'";
return $where;
}
add_filter( 'posts_where', 'filter_where' );
$query = new WP_Query( $query_string );
remove_filter( 'posts_where', 'filter_where' );
but doesn’t show anything
I just want to show a list of post that have been posted in the current month.
went on to the link you posted and put in the code
fine;
I also posted some direct code which is not using the filter – have you tried that?
if you are using your last posted code, do you have a loop added after what you showed here?
just this alone:
$query = new WP_Query( $query_string );
does of course not show anything.
no I don’t think so… its getting a bit confusing for me I must admit.
here is the the whole page of code if this helps
and here is the actual page