Title: get_embed_template
Published: April 12, 2016
Last modified: August 20, 2026

---

# get_embed_template(): string

## In this article

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

Retrieves an embed template path in the current or parent template.

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

The hierarchy for this template looks like:

 1. embed-{post_type}-{post_format}.php
 2. embed-{post_type}.php
 3. embed.php

An example of this is:

 1. embed-post-audio.php
 2. embed-post.php
 3. embed.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 ’embed’.

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

 string Full path to embed template file.

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

    ```php
    function get_embed_template() {
    	$object = get_queried_object();

    	$templates = array();

    	if ( ! empty( $object->post_type ) ) {
    		$post_format = get_post_format( $object );
    		if ( $post_format ) {
    			$templates[] = "embed-{$object->post_type}-{$post_format}.php";
    		}
    		$templates[] = "embed-{$object->post_type}.php";
    	}

    	$templates[] = 'embed.php';

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

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

## 󠀁[Related](https://developer.wordpress.org/reference/functions/get_embed_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.

  | 
| [get_post_format()](https://developer.wordpress.org/reference/functions/get_post_format/)`wp-includes/post-formats.php` |

Retrieve the format slug for a post

  |

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

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

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fsummer-heart-0930.chufeiyun1688.workers.dev%3A443%2Fhttps%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fget_embed_template%2F)
before being able to contribute a note or feedback.