get_archive_template

Retrieve path of archive template in current or parent template.

Description

(string) get_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_archive_template' ) ) { 
  2. require_once ABSPATH . WPINC . '/template.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = get_archive_template(); 
  7.  

Defined (1)

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

/wp-includes/template.php  
  1. function get_archive_template() { 
  2. $post_types = array_filter( (array) get_query_var( 'post_type' ) ); 
  3.  
  4. $templates = array(); 
  5.  
  6. if ( count( $post_types ) == 1 ) { 
  7. $post_type = reset( $post_types ); 
  8. $templates[] = "archive-{$post_type}.php"; 
  9. $templates[] = 'archive.php'; 
  10.  
  11. return get_query_template( 'archive', $templates );