Title: get_tag_template
Published: April 25, 2014
Last modified: May 20, 2026

---

# get_tag_template(): string

## In this article

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

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

Retrieves path of tag template in current or parent template.

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

The hierarchy for this template looks like:

 1. tag-{slug}.php
 2. tag-{id}.php
 3. tag.php

An example of this is:

 1. tag-wordpress.php
 2. tag-3.php
 3. tag.php

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 ‘tag’.

### 󠀁[See also](https://developer.wordpress.org/reference/functions/get_tag_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_tag_template/?output_format=md#return)󠁿

 string Full path to tag template file.

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

    ```php
    function get_tag_template() {
    	$tag = get_queried_object();

    	$templates = array();

    	if ( ! empty( $tag->slug ) ) {

    		$slug_decoded = urldecode( $tag->slug );
    		if ( $slug_decoded !== $tag->slug ) {
    			$templates[] = "tag-{$slug_decoded}.php";
    		}

    		$templates[] = "tag-{$tag->slug}.php";
    		$templates[] = "tag-{$tag->term_id}.php";
    	}
    	$templates[] = 'tag.php';

    	return get_query_template( 'tag', $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.0/src/wp-includes/template.php#L300)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.0/src/wp-includes/template.php#L300-L318)

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

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

Retrieves the currently queried object.

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

Retrieves path to a template.

  |

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

| Version | Description | 
| [4.7.0](https://developer.wordpress.org/reference/since/4.7.0/) | The decoded form of `tag-{slug}.php` was added to the top of the template hierarchy when the tag slug contains multibyte characters. | 
| [2.3.0](https://developer.wordpress.org/reference/since/2.3.0/) | Introduced. |

## User Contributed Notes

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