1

As I understand, index.php (a required template) is used when a more specific template is unavailable---according to the template hierarchy.

My question is, if I create all the specific templates that my theme uses (e.g., home.php, single.php, page.php, search.php, archive.php, 404.php, etc...), then why bother writing any markup in index.php at all? I might as well just leave it blank? Is there a reason to fill out index.php?

1

WordPress might extend the existing template hierarchy in a future version. Your users would get a blank page after an upgrade. So write at least the basic loop, header, footer and pagination.

Another point: I use and see at the index.php usually as the default template. I treat its layout as the core concept and all other templates as specialized variations. Your theme will be easier to understand if you build a complete index.php that doesn’t look like a forgotten stepchild.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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