The filename of a Page’s assigned custom template is stored as the value of a Custom Field with a key named '_wp_page_template' (in the wp_postmeta database table). If the template is stored in a Theme’s subdirectory (or a Parent Theme’s subdirectory of a Child Theme), the value of the wp_postmeta is both the folder and file names, e.g.
my-templates/my-custom-template.php
The function get_page_template_slug() returns an empty string when the value of '_wp_page_template' is either empty or 'default'.
Custom fields starting with an underscore do not display in the Edit screen’s Custom Fields module. To retrieve a Page’s custom template metadata, you can also use:
If you need reverse engineering to find all the pages that are working under a particular page template filename, this is one solution that may work for you.
And it will return (array|false) list of pages matching by that page template filename.
Generally, it happens that inside a theme you build, you need to find a certain page that works under a special custom template and that you need to dynamically access its ID, content, title, etc, and this function will help for that.
You must log in before being able to contribute a note or feedback.
Display the page template filename of the current page:
If you need reverse engineering to find all the pages that are working under a particular page template filename, this is one solution that may work for you.
You can use this function for example:
And it will return (array|false) list of pages matching by that page template filename.
Generally, it happens that inside a theme you build, you need to find a certain page that works under a special custom template and that you need to dynamically access its ID, content, title, etc, and this function will help for that.