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 must be thick, but I could use some help grasping the way template files are chosen to be used. I noticed loop.php is no longer around, and looking at the file structure for twentytwelve there is now a 'page-templates' directory. As well as content-* files. We have index.php, page.php, content.php which one is used when? I know index.php is the "last resort" choice, however does content or page come first? And what is the difference between them? Thank you.

share|improve this question
    
Have you looked at the graphic in the codex: codex.wordpress.org/… content.php is likely a template part. –  helgatheviking Sep 29 '12 at 20:04
    
Yeah I have checked that out, somehow it confuses me. I am certain I am over-analyzing this somehow lol ;) –  thatryan Sep 29 '12 at 20:14
add comment

1 Answer

up vote 1 down vote accepted

Template hierarchy consist of templates, but not every template file is necessarily in hierarchy.

Essentially hierarchy determines entry points (one of matching templates with pre-defined name structure), but from there template can further load additional arbitrary files.

page-templates directory holds custom templates for pages (is_page() branch in hierarchy). It's recent development that they can now reside in sub-folder.

content-*.php templates are called by Twenty Twelve like this from other templates: get_template_part( 'content', get_post_format() );. They are named arbitrarily and not part of template hierarchy - just a code organization choice that developers of this specific theme made.

share|improve this answer
    
Thank you, that cleared it up :) –  thatryan Sep 30 '12 at 6:41
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.