Support » Themes and Templates » Display template by file name

Display template by file name

  • Is there a way to grab the file name of the template being used for the current page/single?

Viewing 5 replies - 1 through 5 (of 5 total)
  • whooami



    current page/single?

    what is that?

    if you have one, page.php handles pages.
    if you have one, single.php handles single post views

    I realize that doesnt answer your question, there is a way to do that, yes, but it’s much easier to just tell you the above,

    you could try this:

    echo $_SERVER[‘PHP_SELF’];

    thx for the reply! in placing the code…

    index.php is returned for each and every page.

    To clarify, I am looking for the template filename.

    I have created custom page templates, and I would like to write some conditions specific to a template filename. For example if the template has ‘form’ in its name then do xy or z.

    for anyone wanting the solution, try this on for size:


    Thanks for finding your own question out Shua…I was wondering the same thing. And if you want to get just the name of the file instead of the path. I used the following:

    $temp = get_page_template();
    $path = pathinfo($temp);
    $temp = $path['filename'] . "." . $path['extension'];
Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Display template by file name’ is closed to new replies.