I am newbie in web development. I am discovering wordpress templates now. They all have similar structure. But I have noticed one interesting thing for me.
There are function calls in php template files. Like get_header(), get_footer()
. But I don’t understand how does PHP interpreter know about this functions, there are not any includes,requires ….
How does this work, please explain this. I would be very grateful for any help.
Leave a Reply
You must be logged in to post a comment.
Take a look at the files starting with index.php in the WordPress folder, which is the first file that get’s loaded. You will see “
require( dirname( __FILE__ ) . '/wp-blog-header.php' );
“, and that’s just the beginning.So to answer your question, wordpress uses “require” to include files.
Read the docs:
Source: http://codex.wordpress.org/Function_Reference/get_header
Source: http://codex.wordpress.org/Function_Reference/get_footer
You may be able to get help on WordPress Development.
The php template files itself are included somewhere. For example:
All the functions that are in a wordpress theme have been declared somewhere else in the core code of WordPress before the template is loaded.
is defined in wp-includes/general-template.php.
So how is wp-includes/general-template.php included?
Every page request starts by loading index.php.
If you are using Linux, you can find references to file by using grep. E.g.
returns a list of files where the get_header() function is defined.