- This topic has 2 replies, 2 voices, and was last updated 8 years, 8 months ago by .
- The forum ‘General Discussion’ is closed to new topics and replies.
These forums are for general discussion on WordPress and Genesis. Official support for StudioPress themes is offered exclusively at My StudioPress. Responses in this forum are not guaranteed. Please note that this forum will require a new username, separate from the one used for My.StudioPress.
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.
© 2023 WPEngine, Inc.