WordPress is_time() Function

Beginner
4 min read
Updated: Nov 2026
3 examples
Conditional tag

Definition

In WordPress, is_time() returns true on a time-based archive. That is an archive of posts by hour, minute, or second, such as /?hour=14.

This is a rare type of archive. Most sites only use year, month, and day archives. The tag is part of is_date(), which is true for all date and time archives.

Syntax

Use it as the test of an if statement.

WordPress
if ( is_time() ) {
  // code for the true path
} else {
  // code for the false path
}
CallWhat it does
is_time()True on an hour, minute, or second archive.
is_day()True on a daily archive.
is_date()True on any date or time archive.

WordPress does not make pretty URLs for time archives. They use query strings such as ?hour=14&minute=30.

Full declaration
WordPress
is_time(): bool

Parameters

ParameterDescription
NoneThis function takes no parameters.

Return Value

Return ValueDescription
booltrue if the main query is for a time archive, otherwise false.

WordPress Examples

Three short theme examples. Each one shows what prints on the true path and the false path.

Example 1 — Detect a time archive

Print a message on time archives.

WordPress
<?php if ( is_time() ) {
  echo 'Posts from a specific time.';
} ?>

How It Works

  1. is_time() is true when an hour, minute, or second is in the query.
  2. A daily archive is not a time archive.
  3. The message is printed only on time archives.

Example 2 — Check from narrow to wide

Pick the most exact type first.

WordPress
<?php
if ( is_time() ) {
  echo 'Time archive';
} elseif ( is_day() ) {
  echo 'Day archive';
} elseif ( is_date() ) {
  echo 'Month or year archive';
} ?>

How It Works

  1. is_time() is tested first.
  2. is_day() is tested next.
  3. is_date() is left for months and years.

Example 3 — Read the hour

Print the hour from the query.

WordPress
<?php if ( is_time() ) {
  echo 'Hour: ' . get_query_var( 'hour' );
} ?>

How It Works

  1. get_query_var( 'hour' ) reads the hour.
  2. It is set only on time archives.
  3. Other pages skip the code.

Frequently Asked Questions

It returns true or false (a bool). Use it inside an if statement.
No. Most sites never link to them. They exist for completeness.
No. A daily archive uses is_day(). Time archives need an hour, minute, or second.
Yes. is_date() covers year, month, day, and time archives.
Conditional tags need the main query. Call them in template files or on hooks such as wp or template_redirect, not directly at the top of functions.php.

Next: is_trackback()

Check if the request is for a trackback.

is_trackback() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

10 people found this page helpful