@Herm71's WordPress WP-ENV Dev Environment
This workflow assumes you have Docker running and npm installed.
If wp-env is not installed globally, the command npm install
will install it locally and provide a wp-env
script for running wp-env
.
This setup maps wp-content/themes
to a separate working directory outside this environment. This enables working on themes outside this root
directory, which is my preferred development workflow.
- Block editor currently requires the Gutenberg plugin
- Theme Unit Test, a WordPress export (WXR) file that you can import into a WordPress installation to test your theme
.wp-env.json
that maps theme development directory outside thisroot
environment.htaccess
file for adjusting site (eg., "pretty permalinks")- WordPress Importer plugin for importing default content (such as Theme Unit Test).
- Theme Check plugin for testing theme against the latest WordPress theme standards and practices
- clone this repo to a directory (eg.,
wp-env-site-root/
) andcd
into it - run command:
npm install
ornpm i
- edit
.wp-env.json
to add your dev theme directory as described below - run command:
npm run wp-env start
(or simplywp-env start
if you already havewp-env
installed globally) - visit your new site at http://localhost:8888/
- login to the Dashboard
- default username:
admin
- default password:
password
- default username:
- activate development theme via Dashboard->Appearance->Themes
Your working environment directory setup should look like this after build:
wp-env-site-root/
|---.wp-env.json
|---.htaccess
|---mu-plugins/
|---plugins/
|---theme-check/
|---wordpress-importer/
|---mu-plugins/
|---themes/ # any themes pulled in via git in .wp-env.json. Not dev theme.
dev-theme-dir/
|--[dev theme directory location set up in .wp-env.json]
Edit the "mappings":"wp-content/themes":
value in .wp-env.json
to point to your theme development directory. Your theme will be loaded but not activated in the site's dashboard.
If you were working on a plugin you could add an additional key for "wp-content/plugins":
to the "mappings":
array to point to a development plugin directory.