There has been some discussion in recent weeks about the use of functions.php in the theme folder as oppose to using a plugin instead and the golden rule, in my opinion, is that anything that is not directly related to your WordPress theme should be in a plugin. Here I will outlined how I approach the issue.
Themes these days in WordPress mean you can do practically anything. In fact anything a plugin can do which means running any PHP code you want. However themes are interchangeable, and therefore if you include code in theme when the theme is not active that code will not run.
Therefore my advice, and this is something that I do with every WordPress project that I completed is to create a ‘utility’ plugin with each site. In this plugin is all the non theme related code for the site. Examples of the things I include in these plugins are as follows:
- Custom post types
- Custom taxonomies
- Dashboard modifications
By including these in a plugin rather than a theme means a theme change in the future will not break that functionality of leave you with no custom post types.
Leave a Reply