WPDev.one
Core Function
View Source on Trac ↗

locate_template()

locate_template( mixed $template_names, mixed $load = false, mixed $load_once = true, mixed $args = array() )

Retrieves the name of the highest priority template file that exists.

Parameters 3 required

Name / Type Description
(string

| array) $template_names Template file(s) to search for, in order.

Required
$load
bool

If true the template file will be loaded if it is found.

bool

$load_once Whether to require_once or require. Has no effect if `$load` is false. Default true.

Required
array

$args Optional. Additional arguments passed to the template. Default empty array.

Required

Return Value

(string)
The template filename if one is located.

Function Information

Since Version
2.7.0
Source File
wp-includes/template.php
Advertisement