Displaying year, month and day archives differently

Conditional tags FTW.

  • is_month() : Currently viewing a monthly archive
  • is_day() : Currently viewing a single day archive
  • is_year() : Currently viewing a yearly archive
  • is_time() : Currently viewing a time-based archive (hourly, minute, or even seconds)

So to test for each of these conditions, add something like this to your archive.php (or whatever template is being used for your archive pages):

// Check what posts were returned in order to find what date the archive is for
global $posts; 
$archivedate = strtotime( $posts[0]->post_date);
if (is_day()) {
    echo "Daily archive: ".date('m/d/Y', $archivedate);
} else if (is_month()) {
    echo "Monthly archive: ".date('F Y', $archivedate);
} else if (is_year()) {
    echo "Yearly archive: ".date('Y', $archivedate);
}

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)