When it comes to WordPress theme development, one or the areas that developers often find themselves wrestling with is just how verbose they should make their code.
For example, we’re often taught and strive from principles such as DRY and KISS, but it’s hard to maintain both of these when building WordPress themes from the ground up.
For example (and as according to the Codex):
At the very minimum, a WordPress Theme consists of two files:
– style.css
– index.php
And for anyone who has done extensive work in WordPress development knows this to be true; however, if you’re getting into theme development – that is, specifically for bloggers, or digital publishers – then you know there’s a wide variety of templates that are also supposed by the WordPress Template Hierarchy.
To name a few:
- style.css
- rtl.css
- editor-style.css
- archives.php
- author.php
- category.php
- comments.php
- date.php
- index.php
- single.php
- tag.php
- …and so many more
But here’s the deal: it’s nearly impossible to embrace DRY while simultaneously trying to implement each of these templates.
Instead, we’re left with having to repeat a variety of code all the while doing so when much of the code could be produced though template parts and conditional logic.
Though I’m sure we all fall somewhere in between on this issue, he’s where I’ve landed with respect to the various themes that I’ve developed over the last couples of years.
Continue reading