318 reputation
1210
bio website jakub.chodorowicz.pl
location
age
visits member for 3 years, 9 months
seen Apr 29 at 8:41

Mar
2
accepted get name of the current template file
Nov
22
awarded  Famous Question
Oct
27
awarded  Nice Question
Oct
5
comment get name of the current template file
Yes, it's true. To get the name of included file you'd probably need to use something like this echo __FILE__;
Sep
9
revised get name of the current template file
adding simpler version, direct printing template file name in template file
Apr
15
awarded  Yearling
Dec
5
awarded  Notable Question
Nov
6
awarded  Popular Question
Oct
19
answered Custom Post Type Archives by Date with Custom Permalink
Oct
14
awarded  Critic
Jul
28
awarded  Popular Question
Jun
24
awarded  Student
Apr
9
answered get name of the current template file
Feb
28
awarded  Commentator
Feb
28
revised get name of the current template file
additional info
Feb
28
comment get name of the current template file
@MikeSchinkel - it already has a patch :) core.trac.wordpress.org/ticket/16689
Feb
27
comment get name of the current template file
Yes, the actual need was to display the name of the currently used theme file, the code I posted had a flaw (which can be solved by moving the function out of the main theme folder), but @t31os' solution is much cleaner and fulfills the need, but, if I understand you correctly, the real problem (WP shouldn't try to read functions.php as page template file) still persists. I'll try to post it on trac, haven't done it yet. Greetings!
Feb
27
comment get name of the current template file
@MikeSchinkel - thanks for comment, but doesn't template_include hook, which t31os suggested, solve the issue? Or maybe I've misunderstood you.
Feb
27
comment get name of the current template file
This code is very clean and solves the whole issue. Many thanks!
Feb
27
comment get name of the current template file
The problem wasn't with debug_backtrace() - I can remove all the code and just leave preg_match_all("/Template Name..., or even just // Template Name: and WP treats then functions.php as template file, but thanks for comments - this is such a unique problem that, as you say, it's not fair to say it's a bug. t31os solution is clean and solves the whole issue. Greets.