WordPress is_date() Function

Beginner
4 min read
Updated: Nov 2026
3 examples
Conditional tag

Definition

In WordPress, is_date() returns true on any date-based archive. That means a year, a month, a day, or a time archive.

It is a wide check. If you only want one kind, use is_year(), is_month(), is_day(), or is_time().

Syntax

Use it as the test of an if statement.

WordPress
if ( is_date() ) {
  // code for the true path
} else {
  // code for the false path
}
CallWhat it does
is_date()True on a year, month, day, or time archive.
is_year()True only on a yearly archive.
is_month()True only on a monthly archive.

The URL looks like /2026/11/ for a month or /2026/11/12/ for a day.

Full declaration
WordPress
is_date(): bool

Parameters

ParameterDescription
NoneThis function takes no parameters.

Return Value

Return ValueDescription
booltrue if the main query is for a date archive, otherwise false.

WordPress Examples

Three short theme examples. Each one shows what prints on the true path and the false path.

Example 1 — Print the date heading

Show a heading on every date archive.

WordPress
<?php if ( is_date() ) {
  echo '<h1>' . get_the_archive_title() . '</h1>';
} ?>

How It Works

  1. is_date() is true on year, month, day, and time archives.
  2. get_the_archive_title() returns the right title.
  3. Other pages skip the heading.

Example 2 — Add noindex to date archives

Many sites hide date archives from search engines.

WordPress
function mytheme_noindex_dates() {
  if ( is_date() ) {
    echo '<meta name="robots" content="noindex, follow">';
  }
}
add_action( 'wp_head', 'mytheme_noindex_dates' );

How It Works

  1. The wp_head hook runs after the query is set.
  2. is_date() is true on every date archive.
  3. The meta tag is added only there.

Example 3 — Different intro text

Use if and else for date and non-date pages.

WordPress
<?php if ( is_date() ) {
  echo 'Posts from this period';
} else {
  echo 'Posts from this topic';
} ?>

How It Works

  1. The if branch runs on date archives.
  2. The else branch runs on all other pages.
  3. This is a simple way to change one line of text.

Frequently Asked Questions

It returns true or false (a bool). Use it inside an if statement.
No. A single post has a date, but it is not a date archive. is_date() is true only on the archive pages.
is_date() is true for year, month, day, and time archives. is_day() is true only for a day archive.
Yes. WordPress creates them from your permalink settings, for example /2026/11/.
Conditional tags need the main query. Call them in template files or on hooks such as wp or template_redirect, not directly at the top of functions.php.

Next: is_day()

Check if the current page is a daily archive.

is_day() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

14 people found this page helpful