Tell me more ×
WordPress Answers is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Hello and happy new year

Suppose one has a large theme composed of several post types, page templates and a bunch of custom loops and template parts which is best keeping in separate php files. What's the best practice to organise these files?

For example, suppose I have 10 page templates. How about putting them in a folder named "pages"? And another folder for the archives?

However, how to let Wordpress know where to look for the templates?

Thanks

share|improve this question

1 Answer

up vote 0 down vote accepted

Page templates are special case and since WP 3.4 can be put in subfolder natively. Other than that WP mostly expects flat file structure for templates.

While template hierarchy is easily adjusted (see dynamic filter in get_query_template(), pretty much only thing needed)... From personal experience - overly extensive and nested directory structure for templates makes developer workflow overly unpleasant very fast.

If you have extreme quantity of templates "how to reduce amount?" is better question than "how to stuff them into folders?".

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.