Title: get_archive_template
Published: April 25, 2014
Last modified: August 20, 2026

---

# get_archive_template(): string

## In this article

 * [Description](https://developer.wordpress.org/reference/functions/get_archive_template/?output_format=md#description)
    - [See also](https://developer.wordpress.org/reference/functions/get_archive_template/?output_format=md#see-also)
 * [Return](https://developer.wordpress.org/reference/functions/get_archive_template/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/functions/get_archive_template/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/functions/get_archive_template/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/get_archive_template/?output_format=md#changelog)

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

Retrieves path of archive template in current or parent template.

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

The template hierarchy and template path are filterable via the [‘$type_template_hierarchy’](https://developer.wordpress.org/reference/hooks/type_template_hierarchy/)
and [‘$type_template’](https://developer.wordpress.org/reference/hooks/type_template/)
dynamic hooks, where `$type` is ‘archive’.

### 󠀁[See also](https://developer.wordpress.org/reference/functions/get_archive_template/?output_format=md#see-also)󠁿

 * [get_query_template()](https://developer.wordpress.org/reference/functions/get_query_template/)

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

 string Full path to archive template file.

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

    ```php
    function get_archive_template() {
    	$post_types = array_filter( (array) get_query_var( 'post_type' ) );

    	$templates = array();

    	if ( count( $post_types ) === 1 ) {
    		$post_type   = reset( $post_types );
    		$templates[] = "archive-{$post_type}.php";
    	}
    	$templates[] = 'archive.php';

    	return get_query_template( 'archive', $templates );
    }
    ```

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

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

| Uses | Description | 
| [get_query_var()](https://developer.wordpress.org/reference/functions/get_query_var/)`wp-includes/query.php` |

Retrieves the value of a query variable in the [WP_Query](https://developer.wordpress.org/reference/classes/wp_query/) class.

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

Retrieves path to a template.

  |

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

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

  |

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

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

## User Contributed Notes

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