When is it appropriate to put functions on page template vs. functions.php?

If it is a custom theme for your site then there would no great speed or security improvements by moving functions.

On the other hand if you want to distribute the theme then I recommend having only the minimum php in the page templates files and having the rest of the functions organized in different files. I like the basic theme set up files of the theme to be in the functions.php and the rest in separate organized files. _s does a good job of this. The reason for moving the functions away from the templates files is that it makes it easier to customize and manage. If you need to duplicate a template then you do not end up duplicating functionality.

I would even place the non-presentational functions in a plugin for easy deactivation and management. See this answer for more information.

Leave a Comment