Title: single_month_title
Published: April 25, 2014
Last modified: May 20, 2026

---

# single_month_title( string $prefix = '', bool $display = true ): string|false|null

## In this article

 * [Description](https://developer.wordpress.org/reference/functions/single_month_title/?output_format=md#description)
 * [Parameters](https://developer.wordpress.org/reference/functions/single_month_title/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/functions/single_month_title/?output_format=md#return)
 * [More Information](https://developer.wordpress.org/reference/functions/single_month_title/?output_format=md#more-information)
 * [Source](https://developer.wordpress.org/reference/functions/single_month_title/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/functions/single_month_title/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/single_month_title/?output_format=md#changelog)
 * [User Contributed Notes](https://developer.wordpress.org/reference/functions/single_month_title/?output_format=md#user-contributed-notes)

[ Back to top](https://developer.wordpress.org/reference/functions/single_month_title/?output_format=md#wp--skip-link--target)

Displays or retrieves page title for post archive based on date.

## 󠀁[Description](https://developer.wordpress.org/reference/functions/single_month_title/?output_format=md#description)󠁿

Useful for when the template only needs to display the month and year, if either
are available. The prefix does not automatically place a space between the prefix,
so if there should be a space, the parameter value will need to have it at the end.

## 󠀁[Parameters](https://developer.wordpress.org/reference/functions/single_month_title/?output_format=md#parameters)󠁿

 `$prefix`stringoptional

What to display before the title.

Default:`''`

`$display`booloptional

Whether to display or retrieve title.

Default:`true`

## 󠀁[Return](https://developer.wordpress.org/reference/functions/single_month_title/?output_format=md#return)󠁿

 string|false|null False if there’s no valid title for the month. Title when retrieving.

## 󠀁[More Information](https://developer.wordpress.org/reference/functions/single_month_title/?output_format=md#more-information)󠁿

 * This tag only works when the `m` or archive month argument has been passed by
   WordPress to the current page (this occurs when viewing a monthly archive page).
 * This tag works only on date archive pages, not on category templates or others.
 * It does not support placing the separator after the title, but by leaving the
   prefix parameter empty, you can set the title separator manually.

## 󠀁[Source](https://developer.wordpress.org/reference/functions/single_month_title/?output_format=md#source)󠁿

    ```php
    function single_month_title( $prefix = '', $display = true ) {
    	global $wp_locale;

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

    	if ( ! empty( $monthnum ) && ! empty( $year ) ) {
    		$my_year  = $year;
    		$my_month = $wp_locale->get_month( $monthnum );
    	} elseif ( ! empty( $m ) ) {
    		$my_year  = substr( $m, 0, 4 );
    		$my_month = $wp_locale->get_month( substr( $m, 4, 2 ) );
    	}

    	if ( empty( $my_month ) ) {
    		return false;
    	}

    	$result = $prefix . $my_month . $prefix . $my_year;

    	if ( ! $display ) {
    		return $result;
    	}
    	echo $result;
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/general-template.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.0/src/wp-includes/general-template.php#L1670)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.0/src/wp-includes/general-template.php#L1670-L1695)

## 󠀁[Related](https://developer.wordpress.org/reference/functions/single_month_title/?output_format=md#related)󠁿

| Uses | Description | 
| [get_query_var()](https://developer.wordpress.org/reference/functions/get_query_var/)`wp-includes/query.php` |

Retrieves the value of a query variable in the [WP_Query](https://developer.wordpress.org/reference/classes/wp_query/) class.

  | 
| [WP_Locale::get_month()](https://developer.wordpress.org/reference/classes/wp_locale/get_month/)`wp-includes/class-wp-locale.php` |

Retrieves the full translated month by month number.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/single_month_title/?output_format=md#changelog)󠁿

| Version | Description | 
| [0.71](https://developer.wordpress.org/reference/since/0.71/) | Introduced. |

## 󠀁[User Contributed Notes](https://developer.wordpress.org/reference/functions/single_month_title/?output_format=md#user-contributed-notes)󠁿

 1.   [Skip to note 2 content](https://developer.wordpress.org/reference/functions/single_month_title/?output_format=md#comment-content-1075)
 2.    [Codex](https://profiles.wordpress.org/codex/)  [  10 years ago  ](https://developer.wordpress.org/reference/functions/single_month_title/#comment-1075)
 3.  [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fsingle_month_title%2F%23comment-1075)
     Vote results for this note: 0[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fsingle_month_title%2F%23comment-1075)
 4.  **Month and Year on New Lines**
 5.  Displays the title, placing month and year on new lines.
 6.      ```php
         <p><?php single_month_title('<br />') ?></p>
         ```
     
 7.  Output is following 2 lines.
 8.      ```php
         December
         2004
         ```
     
 9.   [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fsingle_month_title%2F%3Freplytocom%3D1075%23feedback-editor-1075)

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fsingle_month_title%2F)
before being able to contribute a note or feedback.