Languages: English • Italiano • 日本語 (Add your language)
Require once the template file with WordPress environment.
The globals are set up for the template file to ensure that the WordPress environment is available from within the function. The query variables are also available.
<?php load_template( $_template_file, $require_once ) ?>
if ( $overridden_template = locate_template( 'some-template.php' ) ) { // locate_template() returns path to file // if either the child theme or the parent theme have overridden the template load_template( $overridden_template ); } else { // If neither the child nor parent theme have overridden the template, // we load the template from the 'templates' sub-directory of the directory this file is in load_template( dirname( __FILE__ ) . '/templates/some-template.php' ); }
Since: 1.5.0
load_template() is located in wp-includes/template.php
.
Template Functions: locate_template(), load_template(), get_template(), get_template_part(), get_template_directory(), get_template_directory_uri(), get_page_templates(), comments_template(), get_query_template(), is_page_template()