WordPress single_month_title() Function

Beginner
4 min read
Updated: Nov 2026
3 examples
Archive title

Definition

In WordPress, single_month_title() shows the month and year of the current monthly archive, for example "November 2026".

It works on monthly archive pages. The tag is_month() tells you when you are on one.

Syntax

Pass a space as the prefix so the month and year are separated.

WordPress
<?php
single_month_title( ' ' );
CallWhat it does
single_month_title( ' ' )Prints "November 2026".
single_month_title( '' )Prints "November2026" (no gap).
single_month_title( ' ', false )Returns the text instead of printing.

The prefix goes between the month and the year.

Full declaration
WordPress
single_month_title( string $prefix = '', bool $display = true ): string|false|void

Parameters

ParameterDescription
$prefixstring. Text placed between the month and the year (and it is printed before the year). Use ' ' for a normal space.
$displaybool. true (default) prints the text. false returns it.

Return Value

Return ValueDescription
voidWhen $display is true, the month and year are printed.
string|falseWhen $display is false, the text is returned, or false if there is no month.

WordPress Examples

Three short theme examples. Each one shows the code and what it prints.

Example 1 — Monthly archive heading

Print the month in an h1.

WordPress
<h1>Posts from <?php single_month_title( ' ' ); ?></h1>

How It Works

  1. The visitor is on the November 2026 archive.
  2. The prefix is a space.
  3. The browser shows one space, so the heading reads "Posts from November 2026".

Example 2 — Return the text

Use the text in a sentence.

WordPress
<?php
if ( is_month() ) {
  $when = single_month_title( ' ', false );
  echo 'Archive for' . esc_html( $when );
}

How It Works

  1. is_month() checks for a monthly archive.
  2. The returned text starts with the prefix space.
  3. The sentence joins neatly.

Example 3 — A different separator

Use a dash as the prefix.

WordPress
<h2><?php single_month_title( ' - ' ); ?></h2>

How It Works

  1. The prefix is printed before the month and before the year.
  2. That is why the dash shows twice.
  3. A plain space is usually the best choice.

Frequently Asked Questions

It prints or returns the month and year of the current monthly archive, such as November 2026.
The prefix is empty. Pass a space, single_month_title( ' ' ), to separate the month and year.
On a monthly archive page. Use is_month() to check first.
It returns false when there is no month in the request.

Next: single_post_title()

Print or return the title of the current post or Page.

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

7 people found this page helpful