Using WordPress ‘get_front_page_template()’ PHP function

The get_front_page_template() WordPress PHP function retrieves the path of the front page template in the current or parent theme.


$template_path = get_front_page_template();


  • None

More information

See WordPress Developer Resources: get_front_page_template()


Display Front Page Template Name

This code will display the front page template name.

$template_path = get_front_page_template();
$template_name = basename($template_path, '.php');
echo "Front page template: " . $template_name;

Check if Front Page Template Exists

This code will check if a front page template exists in the current theme or parent theme.

if (get_front_page_template()) {
    echo "Front page template exists.";
} else {
    echo "Front page template not found.";

Load Custom Content for Front Page Template

This code will load custom content for the front page template if it exists.

if (get_front_page_template()) {
} else {

Custom Front Page Template Fallback

This code will load a custom front page template if the default one is not available.

$template_path = get_front_page_template();
if (!$template_path) {
    $template_path = locate_template('custom-front-page.php');

Filter Front Page Template Hierarchy

This code will add a custom front page template to the hierarchy.

function custom_front_page_template($templates) {
    array_unshift($templates, 'custom-front-page.php');
    return $templates;
add_filter('frontpage_template_hierarchy', 'custom_front_page_template');