Specifically in theme php files, such as say index.php. The very first thing in most theme’s index.php file is a call to get_header() which is most certainly not not defined in index.php, so how does it know about that function?
I’m not very familiar with php, but from what I’ve read just now there is an include and require keyword which work more or less the same way as an import in Java or include in C, which I understand and makes sense. However, the only usage of these keywords in this particular index.php file includes a file that doesn’t contain a definition of get_header(), nor does it have any includes or requires of its own (though it does call some more functions it has no right to know about, much like index) so clearly that’s now how it knows about this function.
Anyway, I was just hoping to remove some of the ‘magic’ from wordpress for myself. Thanks in advance!
Themes’ index.php file is not the main file that’s processed, that one resides in the root directory of your wordpress installation. It calls several files setting up the environment and then loads the template. You might want to look in the
wp-content/pluginsdirectory, maybe starting with theglobals.phpfile to tweak some of the magic.Also the
wp-includesdirectory contains interesting files, theget_header()function is defined ingeneral-template.phpin that directory.