I understand WP well enough to create a custom theme at a basic level, but have no experience with the core code. I've also just finished a book on basic php and mysql coding.

I'd like to look 'under the hood' of WP to try and put those together. Can someone tell me:

  • Where to find the files that code for the WP-Mysql connection? (as in, mysqli_connect ...)
  • Where to find the files that code for the get_header() function? (which I assume will have something like include(header.php) )



1 Answer 1


First off, the usual caveat -- Don't modify core code. (Certainly not on a production site.)

If you read the documentation on the Codex, you'll notice that most if not all of the pages in, say, the Function Reference have a section called Source File. Clicking the link located there will take you to the file in trac where the particular function lives.

For instance, the Codex page for the_ID() points you to wp-includes/post-template.php.

Your specific questions:

Sometimes, though, you'll have to hunt all over the WordPress codebase to follow the track of how does this work? You'll find that functions call other functions, which call other functions, which apply filters, and so forth. There's a lot of digging, sometimes, to understand how something in WordPress actually works. Do it. It's worth it.

  • Thank you so much for this extremely helpful and informative response! Just what I was hoping for; I'll start diggin'. . . Is there, in your knowledge, any generalized tutorial of how to begin leaning wp core? It would be very useful for me to have some structure to my learning around this.
    – Greg
    Jul 13, 2013 at 16:47
  • Not that I know of, sorry.
    – Pat J
    Jul 13, 2013 at 20:33
  • Silly question probably, but maybe I'm lucky. get_header() is still located in the same place, so your answer is still correct. But if I would add the function get_nav() in the same way as that get_header() and get_footer() are written, create such a nav file in the correct folder, and call the function on the pages, do you think that would suffice for it to work? Quite often I need to have the nav outside of the header in the source code. Apr 22 at 10:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.