• Skip to main content
  • Skip to forum navigation

StudioPress

  • Shop for Themes
  • My StudioPress

Forum navigation

  • Home
  • General Genesis Discussions
  • StudioPress Themes
  • Genesis Blocks
    • Genesis Blocks
    • Genesis Custom Blocks
  • Retired Themes
  • FAQs
  • Forum Rules
  • Internationalization and Translations
  • Forum Bugs and Suggestions
  • Forum Log In

Are You Using The WordPress Block Editor?

Genesis now offers plugins that help you build better sites faster with the WordPress block editor (Gutenberg). Try the feature-rich free versions of each plugin for yourself!

Genesis Blocks Genesis Custom Blocks

Best practice: put code in functions.php or template file?

Welcome!

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.

Log In
Register Lost Password

Community Forums › Forums › Archived Forums › General Discussion › Best practice: put code in functions.php or template file?

This topic is: not resolved

Tagged: best practice, functions.php

  • This topic has 2 replies, 2 voices, and was last updated 8 years, 8 months ago by lucaslem.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • May 27, 2014 at 8:03 pm #107072
    lucaslem
    Member

    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?

    May 29, 2014 at 1:44 am #107255
    Brad Dalton
    Participant

    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.


    Get Help – Book Consultation.

    May 29, 2014 at 9:20 am #107301
    lucaslem
    Member

    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.

  • Author
    Posts
Viewing 3 posts - 1 through 3 (of 3 total)
  • The forum ‘General Discussion’ is closed to new topics and replies.

CTA

Ready to get started? Create a site or shop for themes.

Create a site with WP EngineShop for Themes

Footer

StudioPress

© 2023 WPEngine, Inc.

Products
  • Create a Site with WP Engine
  • Shop for Themes
  • Theme Features
  • Get Started
  • Showcase
Company
  • Brand Assets
  • Terms of Service
  • Accptable Usse Policy
  • Privacy Policy
  • Refund Policy
  • Contact Us
Community
  • Find Developers
  • Forums
  • Facebook Group
  • #GenesisWP
  • Showcase
Resources
  • StudioPress Blog
  • Help & Documentation
  • FAQs
  • Code Snippets
  • Affiliates
Connect
  • StudioPress Live
  • StudioPress FM
  • Facebook
  • Twitter
  • Dribbble