is_month()

Description

The is_month() conditional tag is used to determine if the current page is a monthly archive. This tag may be used in a template file to achieve special formatting for monthly archives vs. daily or yearly archives. The is_month() call does not have to be within the Loop.

Syntax


is_month()

Parameters

This function has no parameters.

Return Value

boolean
  • true if current page is a monthly archive
  • false if current page is not a monthly archive

Examples

Test to Determine Date Archive Timeframe

The following code fragment will display Browsing monthly archive for June 2013 if the current page is a monthly archive page and the selected month is June 2013.

if (is_day())
	echo "<p>Browsing daily archive for ",
	     get_the_time('F j, Y'), "</p>\n";
elseif (is_month())
	echo "<p>Browsing monthly archive for ",
	     get_the_time('F Y'), "</p>\n";
elseif (is_year())
	echo "<p>Browsing yearly archive for ",
	     get_the_time('Y'), "</p>\n";
else
	echo "<p>Unable to determine date archive timeframe</p>\n";

This code might be used in the date.php template prior to the Loop.

References