The functions.php file should be known to every wordpress theme developer, as it’s where all your custom theme code is expected to go, including the loading of special files, scripts and overriding the default, out-of-the-box wordpress functions and javascript files.
However, there are a few things one need to remember when writing code in that file, and it’s not always easy to understand. Specifically, registering and enqueueing scripts can be a bit tricky if you don’t understand how the functions.php file is loaded.
One of the biggest problem is understanding the scope and load/execution time of what is in that file. I’ve scratched my head a few times on it, and hopefully, I now understand it better and will manage to write it down correctly! (more…)