Switch language

wpseek.com
A WordPress-centric search engine for devs and theme authors




get_page_template [ WordPress Function ]

get_page_template ( No parameters )
Returns:
  • (string)
Defined at:



Retrieve path of page template in current or parent template.

Will first look for the specifically assigned page template The will search for 'page-{slug}.php' followed by 'page-id.php' and finally 'page.php'

Source


<?php
function get_page_template() {
    
$id get_queried_object_id();
    
$template get_page_template_slug();
    
$pagename get_query_var('pagename');

    if ( ! 
$pagename && $id ) {
        
// If a static page is set as the front page, $pagename will not be set. Retrieve it from the queried object
        
$post get_queried_object();
        
$pagename $post->post_name;
    }

    
$templates = array();
    if ( 
$template && === validate_file$template ) )
        
$templates[] = $template;
    if ( 
$pagename )
        
$templates[] = "page-$pagename.php";
    if ( 
$id )
        
$templates[] = "page-$id.php";
    
$templates[] = 'page.php';

    return 
get_query_template'page'$templates );
}
?>

Examples [ wp-snippets.com ]

Top Google zoekresultaten

Meer ...

0 User Note(s)

Nog geen één. Wees de eerste!

Nieuw toevoegen ...



HTML5 Powered with CSS3 / Styling, Performance & Integration, and Semantics