WordPress is_archive() Function

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

Definition

In WordPress, is_archive() returns true when the visitor is on an archive page. That includes category, tag, author, date, custom taxonomy, and post type archives.

It is a wide check. Use it when the same layout should work for every archive, for example to print an archive title. For one kind of archive, use a narrow tag such as is_category() or is_author().

Syntax

Use it as the test of an if statement.

WordPress
if ( is_archive() ) {
  // code for the true path
} else {
  // code for the false path
}
CallWhat it does
is_archive()True on any archive page.
is_archive() && ! is_post_type_archive()True on archives that are not post type archives.
is_home()This is the blog posts index. It is not an archive.

The blog posts index (is_home()) and the search page are not archives.

Full declaration
WordPress
is_archive(): bool

Parameters

ParameterDescription
NoneThis function takes no parameters.

Return Value

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

WordPress Examples

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

Example 1 — Print an archive title

Show the archive heading for every archive page.

WordPress
<?php if ( is_archive() ) {
  the_archive_title( '<h1 class="page-title">', '</h1>' );
} ?>

How It Works

  1. is_archive() is true on category, tag, author, and date pages.
  2. the_archive_title() prints the heading that fits the page.
  3. On other pages the code is skipped.

Example 2 — Choose a CSS class

Add a body-like wrapper class for archive pages.

WordPress
<?php $layout = is_archive() ? 'layout-archive' : 'layout-default'; ?>
<div class="<?php echo esc_attr( $layout ); ?>">

How It Works

  1. The short ? : form picks one of two class names.
  2. esc_attr() makes the value safe for HTML.
  3. Your CSS can style .layout-archive separately.

Example 3 — Archive but not a date archive

Combine tags to be more exact.

WordPress
<?php if ( is_archive() && ! is_date() ) {
  echo '<p>Browse by topic.</p>';
} ?>

How It Works

  1. is_archive() is true on every archive.
  2. ! is_date() removes date archives.
  3. && means both parts must be true.

Frequently Asked Questions

It returns true or false (a bool). Use it inside an if statement.
No. The blog posts index is checked with is_home(). is_archive() is for category, tag, author, date, taxonomy, and post type archives.
No. Use is_search() for search results.
Use is_archive() for all archives. Use is_category() when you only want category 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_attachment()

Check if the current page is a single attachment page.

is_attachment() 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.

9 people found this page helpful