is_post_type_archive

Is the query for an existing post type archive page?.

Description

is_post_type_archive( (string) $post_types = '' ); 

Parameters (1)

0. $post_types — Optional. (string) => ''
Post type or array of posts types to check against.

Usage

  1. if ( !function_exists( 'is_post_type_archive' ) ) { 
  2. require_once ABSPATH . WPINC . '/query.php'; 
  3.  
  4. // Optional. Post type or array of posts types to check against. 
  5. $post_types = ''; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = is_post_type_archive($post_types); 
  9.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/query.php  
  1. function is_post_type_archive( $post_types = '' ) { 
  2. global $wp_query; 
  3.  
  4. if ( ! isset( $wp_query ) ) { 
  5. _doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' ); 
  6. return false; 
  7.  
  8. return $wp_query->is_post_type_archive( $post_types );