How does php know about wordpress functions

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.

Related posts

Leave a Reply

5 comments

  1. 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.

  2. 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.

  3. 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.