get_embed_template() WordPress Function

The get_embed_template() function is used to retrieve the embed template for a specific post. This function is useful for customizing the output of your embedded content.

get_embed_template() #

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


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’ and ‘$type_template’ dynamic hooks, where $type is ’embed’.

Top ↑

See also


Top ↑

Return

(string) Full path to embed template file.


Top ↑

Source

File: wp-includes/template.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 );
}


Top ↑

Changelog

Changelog
VersionDescription
4.5.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.