My site's archive page is echoing wrong Month name. Though the URL is 2012/11/, it's echoing the month December 2012.

I found nothing wrong with the code:

if ( is_day() ) :
printf( __( 'Daywise Posts: %s', 'theme-name' ), '<span id="font">' . "<b><i>". get_the_date() . "</b></i>" .  '</span>' );
elseif ( is_month() ) :
printf( __( 'Month-wise Posts: %s', 'theme-name' ), '<span id="font">' . "<b><i>". get_the_date( _x( 'F Y', 'monthly archives date format', 'theme-name' ) ) . "</b></i>".  '</span>' );
elseif ( is_year() ) :
printf( __( 'Year-wise Posts: %s', 'theme-name' ), '<span id="font">' . "<b><i>" . get_the_date( _x( 'Y', 'yearly archives date format', 'theme-name' ) ) . "</b></i>".  '</span>' );
else :
_e( 'Archives', 'theme-name' );

It's WordPress 3.4.2 here.

  • Do you use query_posts() on that page, in a widget or some other code?
    – fuxia
    Commented Dec 29, 2012 at 11:23
  • No, I din't use any query_posts(), I've learned its problems from a stackexchange answer Wherever I needed a query, I used WP_Query(). Commented Dec 30, 2012 at 8:15
  • Here is my whole bunch of code for Archive.php. Commented Dec 30, 2012 at 8:20

1 Answer 1


Try adding the following above the first if statement to see what actual day is being useddisplayed:

echo get_the_date();

It might also help to add the following lines to help debug exactly what the query is doing:

global $wp_query;

The code is correct - so it has to be something else affecting the display. Does it do this for every month or just specific ones?

  • Thanks for your assistance. The date I always get is "26 December 2012" even if I am in "24 November 2012". Same, when I'm in "November 2012", the date echoing is "December 2012". Thing seems to me is that, "26 December 2012" is somewhere stacked default. I've seen all the posts and the very first post I got is of "2012/11/24". Here is the site where I'm working: link. The date showing in the <title></title> tag is showing correctly. Commented Dec 30, 2012 at 6:52
  • The $wp_query(); is showing: object(WP_Query)#598 (47) { ["query_vars"]=> array(55) { ["year"]=> int(2012) ["monthnum"]=> int(11) ["day"]=> int(24), but still the date echoing is December 26, 2012. Commented Dec 30, 2012 at 6:59
  • What are the dates on the posts that are showing? Is there a post from Nov 24?
    – Ed Burns
    Commented Dec 31, 2012 at 5:06
  • I hid the date from the posts. But I tested that the post showing is correct, according to the URL. And the wp_query thing I pasted here is from 24th Nov's archive. So it's echoing the date 24 Nov. That means the query executing is working correctly, but the echoing is not right. Commented Dec 31, 2012 at 6:08
  • 1
    The only thing I can think of is that your header template includes an extra loop or something like that. Try adding this above the first if: wp_reset_query();
    – Ed Burns
    Commented Dec 31, 2012 at 19:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.