Include template functions after the theme is loaded, but before init.

Fixes conflicts with plugins (#5884) when they output content before
init.

2.2 has no fatal error as reported in #5884