Given that functionality and styling often overlap, a lot of code can be placed either in functions.php or in a separate template file (ex: cpt-single.php in the case of a custom post type). Is there a best practice which dictates when one should create a template and when one can just stick the code in functions file?
Depends. For templates most will go in the template but once there its not as flexible as if its in the functions file.
Good question but also fairly broad as well.
I have found WordPress Developers ( Stackexchange ) a good place to post code and ask for feedback as long as its specific to WordPress and not plugins or themes.
Thanks Brad, will definitely check out stackxchange for specific code issues.
I was asking mainly because I read somewhere that it's not a good idea to have a very large functions file, though it was never made clear why nor was specified how many lines actually make the file "large". I find it easier to put my code in functions (even for structural HTML changes) just because I can easily apply that code to (or remove it from) other sections of the site with a quick conditional change.
I will create templates if they make life easier for clients.
Good to know the answer is indeed "it depends" and not some hard and fast rule. Cheers.
You must be logged in to reply to this topic.
Subscribe to get early access to new themes, discounts and brief updates about what's new with StudioPress!