Display Posts from Current Month & Year in a WordPress Template

Hi Y’all,
I was presented with this challenge while putting together a magazine-type site, where the home page was to display articles from the current issue–meaning the current month and year. Checking the forums, I found some solutions, and although the topics have been closed, I have found that they are incomplete. Some call the current month, i.e. “March”, but don’t not discern the current year, showing posts from March 2013, March 2012, etc. And some simply don’t work at all, sorry to say.

Here’s what I came up with, and have proven to work…
$current_year = date(‘Y’, current_time(‘timestamp’));
$current_month = date(‘m’, current_time(‘timestamp’));
if(have_posts()) : while(have_posts()) : the_post();
<?php endwhile; endif; wp_reset_query(); ?>
Of course, there is room to pass way more arguments within query_posts(), but that’s the easy part.


Doug is an experienced project leader who strives to keep our clients' projects flowing smoothly. As a Developer, Doug is able to ensure a high level of customer satisfaction by focusing his efforts on the setup & support of content management systems (i.e. WordPress & Drupal), custom theme development, CSS/HTML coding, and graphic design. When Doug is not working on web projects, he can be found performing with several professional bands around San Diego.

2 thoughts to “Display Posts from Current Month & Year in a WordPress Template”

  1. Hi Doug

    Would you ever have a situation where, on a given date, there aren’t yet any posts for the current month? If so, how did you address the situation when the month rolls over and, at that time at least, there might be no current month posts to display?

    In my case, there are only a few posts each month. I’m thinking that if, on a given date, there are no posts for the current month, then I’ll just display the posts for the previous month. But I’m keen to hear other strategies.



Leave a Reply

Your email address will not be published. Required fields are marked *