WordPress.org

Codex

Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

Function Reference/single month title

Description

Displays or returns the month and year title for the current page. 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).

Note: 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. 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.

Usage

 <?php single_month_title$prefix$display ?> 

Default Usage

 <?php single_month_title(); ?> 

Parameters

prefix
(string) (optional) Text to place before the title.
Default: None
display
(boolean) (optional) Display the title (TRUE), or return the title to be used in PHP (FALSE).
Default: TRUE

Return Value

The generated title will be:

prefix + MONTH + prefix + YEAR

If prefix parameter is '*', an example would be:

*February*2004

Examples

Month and Year on New Lines

Displays the title, placing month and year on new lines.

<p><?php single_month_title('<br />') ?></p>
December
2004

Using $my_month Variable

Returns the title, which is assigned to the $my_month variable. The variable's value is then displayed with the PHP echo command.

<?php $my_month = single_month_title('', false); echo $my_month; ?>

Related

get_calendar(), get_day_link(), get_month_link(), get_the_date(), get_the_time(), get_year_link(), single_month_title(), the_date(), the_date_xml(), the_modified_date(), get_the_modified_date(), the_modified_time(), get_the_modified_time(), the_time()

See also index of Function Reference and index of Template Tags.