WordPress is_month() Function

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

Definition

In WordPress, is_month() returns true on a monthly archive, the page that lists posts of one month. A typical URL is /2026/11/.

It does not match a daily or yearly archive. For those, use is_day() and is_year().

Syntax

Use it as the test of an if statement.

WordPress
if ( is_month() ) {
  // code for the true path
} else {
  // code for the false path
}
CallWhat it does
is_month()True only on a monthly archive.
is_year()True only on a yearly archive.
is_date()True on any date archive.

Print the month name with single_month_title().

Full declaration
WordPress
is_month(): bool

Parameters

ParameterDescription
NoneThis function takes no parameters.

Return Value

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

WordPress Examples

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

Example 1 — Monthly archive title

Print the month and year in a heading.

WordPress
<?php if ( is_month() ) {
  echo '<h1>Archive: ' . single_month_title( ' ', false ) . '</h1>';
} ?>

How It Works

  1. is_month() is true on the month page.
  2. single_month_title() returns the month text when the second argument is false.
  3. Year and day archives skip the code.

Example 2 — Different text by period

Use elseif for several date archive types.

WordPress
<?php
if ( is_month() ) {
  echo 'Posts of the month';
} elseif ( is_year() ) {
  echo 'Posts of the year';
} ?>

How It Works

  1. The first test checks the month.
  2. The second test runs only when the first is false.
  3. Other pages print nothing.

Example 3 — Month but not day

Remember that a day archive is not a month archive.

WordPress
<?php
echo is_month() ? 'month archive' : 'not a month archive';

How It Works

  1. The short ? : form prints one of two texts.
  2. A daily archive is not a monthly archive.
  3. Use is_date() to match both.

Frequently Asked Questions

It returns true or false (a bool). Use it inside an if statement.
No. A daily archive makes is_day() and is_date() true, but not is_month().
Use get_query_var( 'monthnum' ) on a monthly archive.
Yes. Change your permalink structure in Settings > Permalinks.
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_multi_author()

Check if the site has more than one author with published posts.

is_multi_author() 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.

11 people found this page helpful