Example 1 — Yearly archive title
Print the year in a heading.
<?php if ( is_year() ) {
echo '<h1>Posts from ' . get_query_var( 'year' ) . '</h1>';
} ?> How It Works
is_year()is true when only a year is in the URL.get_query_var( 'year' )returns the year.- Month and day archives skip the code.

