WordPress at Your Fingertips

is_year() WP 1.5.0

Determines whether a year archive page is shown (example.com/2009) — page with posts for a specific year. A conditional tag.

This function is a part of is_date() and is_archive() check, so if you use them together, you should use is_year() before those functions, otherwise is_year() condition will never occur.

1 time — 0.00007 sec (very fast) | 50000 times — 0.01 sec (speed of light)

No Hooks.


true|false. Whether the query is for an existing year archive.


if( is_year() ){
	// ...


#1 Display text only on year archive pages

if( is_year() ){
	echo 'This is an archive page for year: for example, such link example.com/2009';

#2 Use of is_archive() and is_year() together in if/else statements

if( is_year() )
	echo 'This is an year archive page.';
elseif( is_archive() )
	echo 'An archive page: day, month, category, tag etc.';
	echo 'This is not an year archive page';

So is_archive() should follow is_year(), otherwise is_year() condition will never occur.


  • Global. WP_Query. $wp_query WordPress Query object.


Since 1.5.0 Introduced.

Code of is_year() WP 5.8

function is_year() {
	global $wp_query;

	if ( ! isset( $wp_query ) ) {
		_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' );
		return false;

	return $wp_query->is_year();

From tag: Conditional tags (page type and request)

More from tag: Conditional tags (all)

More from category: Queries

More from Template Tags: Main Functions

No comments
    Log In