I can create my theme without splitting it into separate files. Why do theme developers split WordPress theme into a few single files like header.php sidebar.php and etc?
3 Answers
You need that for child themes. If you have a separate header.php
a child theme can use its own header.php
and override the parent theme’s file. Plus, header.php
and footer.php
are used in wp-signup.php
.
Another reason is readability: Putting all the code for a theme into just one file gets very messy very fast.
A use case for a compact theme is testing and debugging: My Mini Theme uses just index.php
and comments.php
for output. Whenever a plugin doesn’t do what I expected I use that theme to be sure it is not a theme issue.