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.

I have a general question about the themes development.

When I develop a theme for distribution (free or commercial) is it a better practice to keep all the default templates file in my theme even though i do not use all of them ?

For exemple if i develop a theme without blog feature, is it a good practice to keep single.php, comments.php ... files in my theme ?

I ask this question because when i test my themes with theme-check plugin, all the default templates files seems to be mandatory to pass the test.

What do you think ? what is the best practice ? Thanks for your advices.

share|improve this question
add comment

4 Answers

up vote 1 down vote accepted

It really depends:

  • What is the intended purpose of the Theme? Is it a "special use" Theme, or merely designed for static Pages but not for blog posts?
  • What is the intended distribution method for the Theme?

If the Theme truly is a "special use" Theme, then you only need to include the template files relevant to the intended use. On the other hand, if you've merely designed a static-Page Theme, you really should take the 5 extra minutes required to ensure that the Theme also accommodates blog posts as well. The difference in underlying code between a static Page and a blog post is trivial.

If the Theme is intended to be submitted to the official Theme repository, and is not a "special use" case, then it will be required to support both static Pages and blog posts. The Theme Check Plugin is intended specifically to indicate issues for Themes to be submitted to the official repository, and that therefore must meet the Theme Review guidelines. If you're going to distribute the Theme outside of the repository, then the Theme Check Plugin test results are merely for your own use/information.

share|improve this answer
add comment

Leave the files in.

You designed the theme, but you don't know how the people who download your theme will want to use it. I'm assuming it's a beautiful, well designed, destined to be popular theme; won't it be a disappointment if someone wants to use it for their corporate blog and cant?

share|improve this answer
add comment

If it's going to be distribuated then you should delete every single file not used in your template:

  • the final file will be lighter
  • the customer will find more easily the files he'll want to modify to match his own needs ("where am I supposed to change [whateveryouwant]?")
share|improve this answer
add comment

No, you should include a bare minimum, although how extensive their contents are depends on you.

For example, you would be forgiven for not including an image.php, since WordPress will fall back on to attachment.php, and so on.

You must include an index.php, as it is the main fallback template, even if your theme is intended to use page.php and a custom home template ( home.php ).

I suggest you keep the following files as a minimum regardless of usage:

  • index.php
  • functions.php
  • single.php
  • page.php
  • style.css
share|improve this answer
    
The single.php and page.php template files only need to be included if the Theme is doing anything specific to single blog post or static page output. For a bare minimum requirement list, I would omit these two. –  Chip Bennett Nov 25 '11 at 15:23
    
Since a new WordPress installation will have a post and a page, and since those 2 files act as common fallbacks for a huge number of post types and other templates, it seems wise to bundle a basic version of each –  Tom J Nowell Nov 26 '11 at 2:25
    
functions.php as a sidenote, should be included for utility purpose, even if it's merely an empty file –  Tom J Nowell Nov 26 '11 at 2:25
    
"since those 2 files act as common fallbacks for a huge number of post types and other templates, it seems wise to bundle a basic version of each" - Both single.php and page.php fallback to index.php. In a bare minimum circumstance, including (or not including) single.php/page.php is no different from including (or not including) archive.php, search.php, 404.php, etc. –  Chip Bennett Nov 26 '11 at 3:29
add comment

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.