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.
5 Answers
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.
4 Comments
Read the docs:
...
get_header()is located in wp-includes/general-template.php.
Source: http://codex.wordpress.org/Function_Reference/get_header
...
get_footer()is located in wp-includes/general-template.php.
Source: http://codex.wordpress.org/Function_Reference/get_footer
You may be able to get help on WordPress Development.
Comments
get_header()
is defined in wp-includes/general-template.php.
So how is wp-includes/general-template.php included?
wp-settings.php requires wp-includes/general-template.php.
wp-config.php requires wp-settings.php.
wp-load.php requires wp-config.php.
wp-blog-header.php requires wp-load.php.
index.php requires wp-blog-header.php.
Every page request starts by loading index.php.
If you are using Linux, you can find references to file by using grep. E.g.
grep -r "function get_header(" *
returns a list of files where the get_header() function is defined.