In archive.php, if it is a date archive, can I get the date using a function?

Consider a url like this: myfirstsite/2013/08 - I want to get the 2013/08

1 Answer 1


Use get_query_var() to get the date parts:

$year     = get_query_var('year');
$monthnum = get_query_var('monthnum');
$day      = get_query_var('day');

In wp_title() a call to get_query_var('m') is used for the month too, but I got always just a 0 as value even on an URL like /2008/09/05/.

If you want to print the month name, use:


The month name will be translated by WordPress then.

There are also four conditional functions you can use:


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.