get_embed_template

The timeline below displays how wordpress function get_embed_template has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 5.1

/**
 * Retrieves an embed template path in the current or parent template.
 *
 * 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 {@see '$type_template_hierarchy'}
 * and {@see '$type_template'} dynamic hooks, where `$type` is 'embed'.
 *
 * @since 4.5.0
 *
 * @see get_query_template()
 *
 * @return string Full path to embed template file.
 */
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);
}

WordPress Version: 4.9

/**
 * Retrieves an embed template path in the current or parent template.
 *
 * 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 {@see '$type_template_hierarchy'}
 * and {@see '$type_template'} dynamic hooks, where `$type` is 'embed'.
 *
 * @since 4.5.0
 *
 * @see get_query_template()
 *
 * @return string Full path to embed template file.
 */
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);
}

WordPress Version: 4.7

/**
 * Retrieves an embed template path in the current or parent template.
 *
 * 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 is filterable via the {@see 'embed_template_hierarchy'} hook.
 * The template path is filterable via the {@see 'embed_template'} hook.
 *
 * @since 4.5.0
 *
 * @see get_query_template()
 *
 * @return string Full path to embed template file.
 */
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);
}

WordPress Version: 4.5

/**
 * Retrieves an embed template path in the current or parent template.
 *
 * By default the WordPress-template is returned.
 *
 * The template path is filterable via the dynamic {@see '$type_template'} hook,
 * e.g. 'embed_template'.
 *
 * @since 4.5.0
 *
 * @see get_query_template()
 *
 * @return string Full path to embed template file.
 */
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);
}