Wordpress and PHP template name
It may seem like a strange question, but in Wordpress page templates, the template name is commented at the top like ...
/*
Template Name: Contact Us
*/
If 2 templates have the same template name, they don't appear in the page template options, how does it read the template page name when it is commented out?
source to share
Using the function get_file_data()
.
Read the following data: get_file_data and File Header and this .
source to share
how does it read the name of the template page when reading it?
I have not used the original WordPresses, but I would assume it does not parse it as a php file, but as a text file. It then loops through the string until it finds the template name.
// Edit:
A little more specific information: Wordpress calls the File Header .
Functions that load and parse this file header can be found in wp-includes / functions.php, for example get_file_data. The comment for this function describes the restrictions for the file header.
And you can see that Wordpress actually reads it like a regular file and extracts the information.
source to share