Skip to main content

benecaster_locate_template()

Template Free
benecaster_locate_template( string $template ): string|false

Answers one question: has the theme overridden this template part? It searches the child theme and parent theme only — never the plugin’s own templates/ directory — so a false result means “no override”, not “no such part”.

It does not see add-on template directories either, deliberately. A directory registered with benecaster_register_template_directory() is not a theme override, and this function answers the theme question only. For “which file would actually load?”, use benecaster_get_template_path().

Useful in an add-on that wants to enhance the default markup but back off politely when a podcaster has already customised it.

Parameters

Name Type Default Required Description
$template string — Yes Relative path to the part, e.g. 'episode/title'.

Return Value

Type: string|false

The absolute path to the theme's override file, or false when the theme has not overridden this part.

Example

if ( benecaster_locate_template( 'episode/title' ) ) {
    // The theme has its own episode title part — leave it alone.
}

Need this built rather than just documented? See our services →