WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
Do you use query_posts() on that page, in a widget or some other code? – toscho Dec 29 '12 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(). – Mayeenul Islam Dec 30 '12 at 8:15
Here is my whole bunch of code for Archive.php. – Mayeenul Islam Dec 30 '12 at 8:20
up vote 2 down vote accepted

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?

share|improve this answer
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. – Mayeenul Islam Dec 30 '12 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. – Mayeenul Islam Dec 30 '12 at 6:59
What are the dates on the posts that are showing? Is there a post from Nov 24? – Ed Burns Dec 31 '12 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. – Mayeenul Islam Dec 31 '12 at 6:08
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 Dec 31 '12 at 19:57

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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