Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

My functions.php file is getting on the long side. Is it all right to use includes to break it up (php includes I mean) or is this considered bad form?

share|improve this question

3 Answers 3

up vote 1 down vote accepted

Many theme frameworks and complex themes break up functions into different files and include them in one file called functions.php, sometimes within a folder called inc. If it's your own theme, you can pretty much do what you want.

If it's a theme to be released, end users typically look for a functions.php file as the default WP framework functions file.

The two latest default WP themes - twentyten http://wordpress.org/extend/themes/twentyten and twentyeleven http://wordpress.org/extend/themes/twentyeleven - use one functions.php file, as that's part of the standard WP theme file structure.

But again, many themes use multiple files for functions, and if a user wants to work with or modify the theme, they will need a certain level of proficiency anyway. Code comments are helpful.

share|improve this answer

I think it is down to personal preference - as far as I'm aware there are no conventions that say you should or shouldn't use includes in the functions file.

Personally, I do like to split the functions file up into separate includes - I find it a lot easier to find the section of code I'm looking for when it's in a separate file rather than trawling through 1000's of lines of code.

As long as you comment everything in a meaningful way should anyone else work on the theme in the future they'll be able to understand what you've done and why.

share|improve this answer

If you have anything in the functions.php file that is more of a site function than related directly to the specific theme formatting, you should consider moving to a site-specific plugin.

More on this: http://wpcandy.com/teaches/how-to-create-a-functionality-plugin

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.