Starting a Project
1. Create the repository
The LH WordPress Template is a GitHub template repository. Create the project's repository with Use this template.
2. Install the packages
Use the Node version in .nvmrc / mise.toml, then install the packages.
mise install # or nvm use
npm ci
3. Set up wp-config.php
Set the environment type. Without it, the site is treated as production: the custom field admin screens are hidden, and form mail subjects lose the "【TEST】" prefix even on the test environment.
define('WP_ENVIRONMENT_TYPE', 'local'); // 'staging' for the test environment, 'production' for production
If the forms use reCAPTCHA, define the keys here too. Never write them in the theme.
define('TOFU_RECAPTCHA_SITE_KEY', '...');
define('TOFU_RECAPTCHA_SECRET_KEY', '...');
4. Edit the settings files
Edit the files in settings/ for the project. Delete the samples you don't need: the sample pages, the case study post type and its templates.
- Creating pages
- News (built-in posts)
- Custom post types
- Custom fields
- SEO and Redirects
- Contact forms
5. Open the admin screens
Log in to the admin screens as an administrator. The missing pages are created, and the news URL structure is written to Settings → Permalinks.
Then open Settings → Permalinks once to regenerate the rewrite rules. Opening the screen is enough; you don't need to save. Do the same on the test and production environments after uploading the files.
Development commands
npm run watch # Watch and build the SCSS
npm run build # Build the SCSS
npm run lint # ESLint / Stylelint
npm run convert:webp # Convert the images to WebP
- The SCSS lives in
data/scss/and is built intodata/css/, which git doesn't track. Follow the CSS methodologies. - On every commit, a Git hook converts the JPG and PNG images in
data/img/to WebP and commits them with the change.
Before you finish
- Run
php -lon every PHP file you changed. - Open the pages your change affects on the local site.
- After changing a form, go through input → confirm → result and check the mail. Mail from local and test environments is caught by Mailpit and is never delivered.
- After changing post types or permalinks, open Settings → Permalinks before checking the URLs.