WordPress.org

Codex

Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

Function Reference/get query template

Description

Retrieve path to file without the use of extension.

Used to quickly retrieve the path of file without including the file extension. It will also check the parent template, if the file exists, with the use of locate_template(). Allows for more generic file location without the use of the other get_*_template() functions.

Can be used with include() or require() to retrieve path.

   if ( '' != get_query_template( '404' ) )
       include( get_query_template( '404' ) );

or the same can be accomplished with

   if ( '' != get_404_template() )
       include( get_404_template() );

Usage

<?php get_query_template$type$templates ); ?>

Parameters

$type
(string) (required) Filename without extension.
Default: None
$templates
(array) (optional) An optional list of template candidates
Default: array()

Return Values

(string) 
Full path to file.

Examples

Notes

Change Log

Since: 1.5.0

Source File

get_query_template() is located in wp-includes/template.php.

Related

See also index of Function Reference and index of Template Tags.