Wordpress development in the real world, a 3-part series — Part 1

Jérôme Morlon
4 min readOct 23, 2024

Love it or hate it, Wordpress is still there and developping themes and plugins for it remain an active branch of web software programming in 2024. But how to reconcile Wordpress coding and best practices for clean code? How to use classes, and favor reusability as much as we can? How, even, can we fully abstract templates from Wordpress functions and global variables?

Photo by Fikret tozak on Unsplash

Part 1 — Setting up reusable classes

Our first goal here is to implement reusable classes for some typical CMS features. Those classes will relay on CMS-agnostic PHP interfaces but will of course be written here using Wordpress functions.

Among those classes, we can imagine one handling the global theme configuration, one handling custom editable settings, one responsible for rendering templates, as well as classes for handling posts, terms, queries and external APIs. Depending on our needs, we can also add classes specifically managing the CMS editor, metadata and search, as well as a utilities class and even other types of class.

As a first example, one of the contracts for the rendering class can specify this function, which, as you will have no trouble guessing, will be responsable for rendering a template part.

--

--

Jérôme Morlon
Jérôme Morlon

No responses yet