WordPress is_tax() Function

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

Definition

In WordPress, is_tax() returns true on the archive of a custom taxonomy, for example a genre taxonomy for books.

It does not match categories or tags. Those have their own functions, is_category() and is_tag(). Pass a taxonomy name, and optionally a term, to be more exact.

Syntax

Use it as the test of an if statement.

WordPress
if ( is_tax() ) {
  // code for the true path
} else {
  // code for the false path
}
CallWhat it does
is_tax()True on any custom taxonomy archive.
is_tax( 'genre' )True on any archive of the genre taxonomy.
is_tax( 'genre', 'fiction' )True on the fiction term of the genre taxonomy.

For built-in taxonomies use is_category() and is_tag().

Full declaration
WordPress
is_tax( string|string[] $taxonomy = '', int|string|int[]|string[] $term = '' ): bool

Parameters

ParameterDescription
$taxonomyOptional. A taxonomy name or an array of names. Default is empty, which means any custom taxonomy.
$termOptional. A term ID, name, slug, or an array of them. Default is empty, which means any term.

Return Value

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

WordPress Examples

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

Example 1 — Any custom taxonomy

Print the term name on custom taxonomy archives.

WordPress
<?php if ( is_tax() ) {
  echo '<h1>' . single_term_title( '', false ) . '</h1>';
} ?>

How It Works

  1. is_tax() is true on custom taxonomy archives.
  2. single_term_title() returns the term name.
  3. Categories and tags return false.

Example 2 — One taxonomy

Show a note on every genre archive.

WordPress
<?php if ( is_tax( 'genre' ) ) {
  echo '<p>Browse books by genre.</p>';
} ?>

How It Works

  1. 'genre' is the taxonomy name.
  2. Every term of that taxonomy returns true.
  3. Other taxonomies skip the note.

Example 3 — One term

Match a taxonomy and one term.

WordPress
<?php if ( is_tax( 'genre', 'fiction' ) ) {
  echo '<p>Our best stories.</p>';
} ?>

How It Works

  1. The first argument is the taxonomy.
  2. The second argument is the term slug.
  3. Only that one term returns true.

Frequently Asked Questions

It returns true or false (a bool). Use it inside an if statement.
No. Categories use is_category() and tags use is_tag().
Use register_taxonomy() in your theme or plugin.
Use is_category() || is_tag() || is_tax(). Or use is_archive() for every archive type.
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_time()

Check if the current page is a time-based archive (hour, minute, or second).

is_time() 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