A WordPress-centric search engine for devs and theme authors



get_embed_template ›

Since4.5.0
Deprecatedn/a
get_embed_template ( No parameters )
See:
Returns:
  • (string) Full path to embed template file.
Defined at:
Codex:

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'.



Source

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 );
}