February 2017
Developing a custom WordPress theme: 5 tips for success
Filed under: Web Development, WordPress

Practical advice for planning, building, and testing a custom WordPress theme without losing sight of maintainability.
Plan the template hierarchy first
WordPress decides which template file renders a request through a fixed hierarchy. Sketching which of those files a project actually needs, before writing any of them, prevents the common outcome of one enormous template full of conditional branches.
Build for the person who will edit the content
A theme is used far longer by an editor than by its developer. Field names that describe content rather than layout, and templates that degrade sensibly when a field is left empty, are what separate a theme that survives two years from one that is worked around.
Use the platform's own patterns
Enqueue stylesheets and scripts properly rather than hard-coding tags, escape output, and use the template tags the platform provides. This is dull advice that pays off the first time the site is updated, moved, or handed to somebody else.
Keep the stylesheet structured
A theme's CSS grows faster than anything else in the project. Splitting it into partials with a clear order, and keeping component styles next to the components they belong to, keeps it navigable well past the point where a single file stops working.
Test with real content
Themes look excellent with three tidy demo posts and fall apart with a two-line title, a post with no image, or a category holding a single entry. Testing against the real archive, including its awkward edges, is the fastest route to a theme that holds up.
Next entry: Essential WordPress plugins for your website
Previous entry: Add animated gradients to your website with Javascript
Back to February 2017 or the front page.