locate_template


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

Parameters:
  • (string|array) template_names Template file(s) to search for, in order.
  • (bool) load 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.
  • (array) args Optional. Additional arguments passed to the template. Default empty array.
Returns:
  • (string) The template filename if one is located.
Defined at:
Change Log:
  • 5: .

Description

Retrieves the name of the highest priority template file that exists.Searches in the stylesheet directory before the template directory and wp-includes/theme-compat so that themes which inherit from a parent theme can just overload one file.

Related Functions

load_template, locate_block_template, get_date_template, get_template, get_block_template

Top Google Results

User discussions

wpseek mobile