get_embed_template

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

Description

(string) get_embed_template(); 

The hierarchy for this template looks like:

1. embed--.php 2. embed-.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 hook. The template path is filterable via the hook.

Returns (string)

Full path to embed template file.


Usage

  1. if ( !function_exists( 'get_embed_template' ) ) { 
  2. require_once ABSPATH . WPINC . '/template.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = get_embed_template(); 
  7.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/template.php  
  1. function get_embed_template() { 
  2. $object = get_queried_object(); 
  3.  
  4. $templates = array(); 
  5.  
  6. if ( ! empty( $object->post_type ) ) { 
  7. $post_format = get_post_format( $object ); 
  8. if ( $post_format ) { 
  9. $templates[] = "embed-{$object->post_type}-{$post_format}.php"; 
  10. $templates[] = "embed-{$object->post_type}.php"; 
  11.  
  12. $templates[] = "embed.php"; 
  13.  
  14. return get_query_template( 'embed', $templates );