is_year()

Description

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

Syntax


is_year()

Parameters

This function has no parameters.

Return Value

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

Examples

Test to Determine Date Archive Timeframe

The following code fragment will display Browsing yearly archive for 2013 if the current page is a yearly archive page and the year selected is 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