**Here you go:**

A HTML-list with **all** template files in use for the current landing page, **including all template-parts from plugins, child theme and/ or parent theme combinations**, all in one line of code:

    echo '<ul><li>'.implode('</li><li>', str_replace(get_home_path().'wp-content/', '', array_slice(str_replace('\\', '/', get_included_files()), (array_search(get_home_path().'wp-includes/template-loader.php', str_replace('\\', '/', get_included_files())) + 1)))).'</li></ul>';


You MAY need to **check** that your server *does not returning dubble slashes at any path*. Remember to place this after all template files actually been used, like in footer.php

**To break this up:**

You **can not** collect all included template files without PHP backtrace. **Superglobals** inside `template_include` **wont collect them all**. The other way is to "place a marker" in each template file, but if you need to interact with the files first, you hazzle with time and the whole idea.

**1)** We need to check inside all the files that have been used by current Wordpress request. And they are many! Dont be surprised if you are using 300 files before even your functions.php is registered.

    $included_files = str_replace('\\', '/', get_included_files());

We are using the PHP native get_included_files(), converting backslashes to forward slashes to match most of Wordpress returning paths.

**2)** We are cutting that array from where the template-loader.php is registered. After that, the populated get_included_files() should only have template files populated.

    /* The magic point, we need to find its position in the array */
    $key = get_home_path().'wp-includes/template-loader.php';
    $offset = array_search($key, $included_files);

    /* Get rid of the magic point itself in the new created array */
    $offset = ($offset + 1);
    $output = array_slice($included_files, $offset);

**3)** Shorten down the results, we dont need the path until theme folder or plugin folder, **as templates** in use, **can be mixed** from plugins, theme or child theme folders.

    $replacement = get_home_path().'wp-content/';
    $output = str_replace($replacement, '', $output);

**4)** Finally, convert from array to a nice HTML list

    $output = '<ul><li>'.implode('</li><li>', $output).'</li></ul>';