WordPress Coding Guide
We build websites with either WordPress or the Fegg Framework. This guide covers the rules for WordPress sites.
LH WordPress Template
Every WordPress site starts from the LH WordPress Template. Its theme (htdocs/wp-content/themes/Template/) already has the functions, sample pages and plugin settings described in this guide.
The template's README.md explains how to write each settings file, and its CLAUDE.md gives the same rules to coding agents such as Claude Code.
Design principles
Theme files are the single source of truth
So that the test and production environments don't drift apart, everything that defines the structure of the site is written in theme files. Uploading the files is enough to bring any environment to the same state.
- The database holds content only: body text and the values editors enter.
- Structure is written in files: which pages exist, custom fields, post types, SEO settings, redirects and forms.
- Avoid settings that are made on an admin screen and saved in the database. Keep this in mind when you choose a plugin too.
| What | Where (under the theme) | Page |
|---|---|---|
| Pages | settings/pages.php | Creating pages |
| Post types and taxonomies | settings/post-types/*.php | Custom post types |
| Custom fields | settings/fields/*.php | Custom fields |
| SEO | settings/seo.php and others | SEO |
| Redirects | settings/redirects.php | Redirects |
| Forms | settings/forms/*.php | Contact forms |
Mechanism and definitions are separate
include/holds the mechanism. Don't change it per project.settings/holds the definitions. Edit these per project.
Secrets go in wp-config.php
Never write API keys or other secrets in the theme. Define them as constants in wp-config.php (e.g. TOFU_RECAPTCHA_SITE_KEY).