Title: is_post_type_archive
Published: April 25, 2014
Last modified: February 24, 2026

---

# is_post_type_archive( string|string[] $post_types ): bool

## In this article

 * [Description](https://developer.wordpress.org/reference/functions/is_post_type_archive/?output_format=md#description)
 * [Parameters](https://developer.wordpress.org/reference/functions/is_post_type_archive/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/functions/is_post_type_archive/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/functions/is_post_type_archive/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/functions/is_post_type_archive/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/is_post_type_archive/?output_format=md#changelog)
 * [User Contributed Notes](https://developer.wordpress.org/reference/functions/is_post_type_archive/?output_format=md#user-contributed-notes)

[ Back to top](https://developer.wordpress.org/reference/functions/is_post_type_archive/?output_format=md#wp--skip-link--target)

Determines whether the query is for an existing post type archive page.

## 󠀁[Description](https://developer.wordpress.org/reference/functions/is_post_type_archive/?output_format=md#description)󠁿

For more information on this and similar theme functions, check out the [ Conditional Tags](https://developer.wordpress.org/themes/basics/conditional-tags/)
article in the Theme Developer Handbook.

## 󠀁[Parameters](https://developer.wordpress.org/reference/functions/is_post_type_archive/?output_format=md#parameters)󠁿

 `$post_types`string|string[]optional

Post type or array of posts types to check against. Default empty.

## 󠀁[Return](https://developer.wordpress.org/reference/functions/is_post_type_archive/?output_format=md#return)󠁿

 bool Whether the query is for an existing post type archive page.

## 󠀁[Source](https://developer.wordpress.org/reference/functions/is_post_type_archive/?output_format=md#source)󠁿

    ```php
    function is_post_type_archive( $post_types = '' ) {
    	global $wp_query;

    	if ( ! isset( $wp_query ) ) {
    		_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' );
    		return false;
    	}

    	return $wp_query->is_post_type_archive( $post_types );
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/query.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/6.9.4/src/wp-includes/query.php#L187)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-includes/query.php#L187-L196)

## 󠀁[Related](https://developer.wordpress.org/reference/functions/is_post_type_archive/?output_format=md#related)󠁿

| Uses | Description | 
| [WP_Query::is_post_type_archive()](https://developer.wordpress.org/reference/classes/wp_query/is_post_type_archive/)`wp-includes/class-wp-query.php` |

Determines whether the query is for an existing post type archive page.

  | 
| [__()](https://developer.wordpress.org/reference/functions/__/)`wp-includes/l10n.php` |

Retrieves the translation of $text.

  | 
| [_doing_it_wrong()](https://developer.wordpress.org/reference/functions/_doing_it_wrong/)`wp-includes/functions.php` |

Marks something as being incorrectly called.

  |

[Show 1 more](https://developer.wordpress.org/reference/functions/is_post_type_archive/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/functions/is_post_type_archive/?output_format=md#)

| Used by | Description | 
| [wp_get_document_title()](https://developer.wordpress.org/reference/functions/wp_get_document_title/)`wp-includes/general-template.php` |

Returns document title for the current page.

  | 
| [get_the_archive_description()](https://developer.wordpress.org/reference/functions/get_the_archive_description/)`wp-includes/general-template.php` |

Retrieves the description for an author, post type, or term archive.

  | 
| [get_the_archive_title()](https://developer.wordpress.org/reference/functions/get_the_archive_title/)`wp-includes/general-template.php` |

Retrieves the archive title based on the queried object.

  | 
| [feed_links_extra()](https://developer.wordpress.org/reference/functions/feed_links_extra/)`wp-includes/general-template.php` |

Displays the links to the extra feeds such as category feeds.

  | 
| [wp_title()](https://developer.wordpress.org/reference/functions/wp_title/)`wp-includes/general-template.php` |

Displays or retrieves page title for all areas of blog.

  | 
| [post_type_archive_title()](https://developer.wordpress.org/reference/functions/post_type_archive_title/)`wp-includes/general-template.php` |

Displays or retrieves title for a post type archive.

  | 
| [WP::handle_404()](https://developer.wordpress.org/reference/classes/wp/handle_404/)`wp-includes/class-wp.php` |

Set the Headers for 404, if nothing is found for requested URL.

  | 
| [_wp_menu_item_classes_by_context()](https://developer.wordpress.org/reference/functions/_wp_menu_item_classes_by_context/)`wp-includes/nav-menu-template.php` |

Adds the class property classes for the current context, if applicable.

  | 
| [get_body_class()](https://developer.wordpress.org/reference/functions/get_body_class/)`wp-includes/post-template.php` |

Retrieves an array of the class names for the body element.

  |

[Show 4 more](https://developer.wordpress.org/reference/functions/is_post_type_archive/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/functions/is_post_type_archive/?output_format=md#)

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/is_post_type_archive/?output_format=md#changelog)󠁿

| Version | Description | 
| [3.1.0](https://developer.wordpress.org/reference/since/3.1.0/) | Introduced. |

## 󠀁[User Contributed Notes](https://developer.wordpress.org/reference/functions/is_post_type_archive/?output_format=md#user-contributed-notes)󠁿

 1.   [Skip to note 4 content](https://developer.wordpress.org/reference/functions/is_post_type_archive/?output_format=md#comment-content-962)
 2.    [Codex](https://profiles.wordpress.org/codex/)  [  10 years ago  ](https://developer.wordpress.org/reference/functions/is_post_type_archive/#comment-962)
 3.  [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fis_post_type_archive%2F%23comment-962)
     Vote results for this note: 4[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fis_post_type_archive%2F%23comment-962)
 4.  **Example**
      If the current page is an archive of a [custom post type](https://developer.wordpress.org/themes/basics/post-types/#custom-post-types),
     display the custom post type title:
 5.      ```php
         <?php if ( is_post_type_archive() ) { ?>
         <h1><?php post_type_archive_title(); ?></h1>
         <?php } ?>
         ```
     
 6.  **Notes**
      This returns true for a page like` /?post_type=my-custom-post-type`,
     but _not_ for `/category/uncategorized/?post_type=custom`. It’s only testing whether
     this is an archive of all posts of a given type. It is _not_ checking for the 
     existence of the `post_type` query parameter — that can be found by [`get_query_var('post_type')`](https://developer.wordpress.org/reference/functions/get_query_var/).
 7.  Also, depending on when this function runs it may or may not be run by `nav_menu_item`.
     For example:
 8.      ```php
         <?php
         function wpdocs_my_function( $query ) {
             if ( is_post_type_archive( 'my_custom_post_type' ) ) {
                  // Do stuff
             }
         }
         add_action( 'pre_get_posts', 'wpdocs_my_function' );
         ?>
         ```
     
 9.  Whether “Do stuff” gets run in the menu depends on whether the theme use nav menus.
     A better usage would be:
 10.     ```php
         <?php
         function wpdocs_my_function( $query ) {
             if ( is_post_type_archive( 'my_custom_post_type' ) && 'my_custom_post_type' === $query->query['post_type'] ) {
                  // Do stuff
             }
         }
         add_action( 'pre_get_posts', 'wpdocs_my_function' );
         ?>
         ```
     
 11.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fis_post_type_archive%2F%3Freplytocom%3D962%23feedback-editor-962)
 12.  [Skip to note 5 content](https://developer.wordpress.org/reference/functions/is_post_type_archive/?output_format=md#comment-content-5179)
 13.   [Muhammad Ayoub](https://profiles.wordpress.org/mohammadayoub96/)  [  5 years ago  ](https://developer.wordpress.org/reference/functions/is_post_type_archive/#comment-5179)
 14. [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fis_post_type_archive%2F%23comment-5179)
     Vote results for this note: 0[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fis_post_type_archive%2F%23comment-5179)
 15. Conditionally enqueue (add) styles/scripts with custom post type archive page
 16.     ```php
         add_action( 'wp_enqueue_scripts', function() {
             // check if this is snippets archive page
             if ( is_post_type_archive( 'snippets' ) ) {
                 wp_enqueue_style( 'wpdocs-style-name', get_stylesheet_uri() );
                 wp_enqueue_script( 'wpdocs-script-name', get_template_directory_uri() . '/js/example.js', array(), '1.0.0', true );
             }
         } );
         ```
     
 17.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fis_post_type_archive%2F%3Freplytocom%3D5179%23feedback-editor-5179)
 18.  [Skip to note 6 content](https://developer.wordpress.org/reference/functions/is_post_type_archive/?output_format=md#comment-content-961)
 19.   [Codex](https://profiles.wordpress.org/codex/)  [  10 years ago  ](https://developer.wordpress.org/reference/functions/is_post_type_archive/#comment-961)
 20. [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fis_post_type_archive%2F%23comment-961)
     Vote results for this note: -5[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fis_post_type_archive%2F%23comment-961)
 21. **Usage**
 22.     ```php
         <?php is_post_type_archive( $post_types ); ?>
         ```
     
 23.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fis_post_type_archive%2F%3Freplytocom%3D961%23feedback-editor-961)

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fis_post_type_archive%2F)
before being able to contribute a note or feedback.