get_post_type_archive_template

Retrieve path of post type archive template in current or parent template.

Description

(string) get_post_type_archive_template(); 

The template hierarchy is filterable via the hook. The template path is filterable via the hook.

Returns (string)

Full path to archive template file.


Usage

  1. if ( !function_exists( 'get_post_type_archive_template' ) ) { 
  2. require_once ABSPATH . WPINC . '/template.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = get_post_type_archive_template(); 
  7.  

Defined (1)

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

/wp-includes/template.php  
  1. function get_post_type_archive_template() { 
  2. $post_type = get_query_var( 'post_type' ); 
  3. if ( is_array( $post_type ) ) 
  4. $post_type = reset( $post_type ); 
  5.  
  6. $obj = get_post_type_object( $post_type ); 
  7. if ( ! $obj->has_archive ) 
  8. return ''; 
  9.