This guide will walk you through setting up the WordPress site for local development.
- Git
- Code editor (recommended: VS Code)
- Node.js and npm
- PHP
- Composer (also available via Homebrew)
Both are from WP Engine and are really well integrated.
- Install the WP Migrate Pro plugin on the production/staging site.
- Go to the plugin settings and enable
PullandPushpermissions on the site.
- Download, install, and open the Local app on you computer.
- Go to the app settings/preferences and configure some useful settings:
- New site defaults:
- Environment:
Custom - Admin e-mail: (whatever you want)
- Domain suffix:
.local - Site path: (whatever you want)
- Environment:
- Advanced:
- Router mode: choose
Site domainsinstead oflocalhostto be able to use the "Copy block styles" feature of WordPress block editor
- Router mode: choose
- New site defaults:
Follow the WP Migrate guide on how to import a WordPress Site to Local.
Once the site has been imported to Local:
- In the Local app, select the project from the list of sites in the sidebar and launch it.
Overviewtab →SSL: Click theTrustbutton. Close the program. On macOS, open theKeychain Accessapp, selectSystemin the left panel, then selectCertificatesin the right panel. The certificate with the name of the domain you just created will appear there. If a red message appears saying that the certificate is not trusted, open it, click on the Trust drop-down menu, select theAlways Trustoption, close the certificate window, enter your password if prompted, and the message should now appear marked as trusted with a blue + icon. Close the app, reopen theLocalapp, and check that it works (it should sayTrusted). More info.Overviewtab →One-click admin: Activate it (toggle →ON) and choose the corresponding user.Toolstab →Instant Reload: Activate it (toggle →ON).- Open the local site admin, go to
Settings→General, and in theWordPress Address (URL)andSite Address (URL)fields, replacehttpwithhttps.
Open the wp-config.php file, which is located in your_local_site_directory/app/public/wp-config.php, and only replace all the lines of code from
/* For developers: WordPress debugging mode. */
to
/* That's all, stop editing! */
(both included), with the following content:
/**
* For developers: WordPress debugging mode.
*
* Change this to true to enable the display of notices during development.
* It is strongly recommended that plugin and theme developers use WP_DEBUG
* in their development environments.
*
* For information on other constants that can be used for debugging,
* visit the documentation.
*
* @link https://developer.wordpress.org/advanced-administration/debug/debug-wordpress/
*
* Also:
* When you are actively developing with theme.json you may notice it takes 30+ seconds for your changes to show up in the browser, this is because theme.json is cached. To remove this caching issue, set either WP_DEBUG or SCRIPT_DEBUG to ‘true’ in your wp-config.php. This tells WordPress to skip the cache and always use fresh data.
*
* @link https://developer.wordpress.org/block-editor/how-to-guides/themes/global-settings-and-styles/#why-does-it-take-so-long-to-update-the-styles-in-the-browser
* @link https://developer.wordpress.org/advanced-administration/debug/debug-wordpress/#wp_debug
*/
if (!defined("WP_DEBUG")) {
define("WP_DEBUG", true);
}
/**
* Set the environment type to 'local'.
*/
define("WP_ENVIRONMENT_TYPE", "local");
/**
* Set the development mode for the site to 'all'.
*
* Reason: 'all' indicates that this site is used as a WordPress development environment where all three aspects may be modified. For example, this may be relevant when you are working on a specific site as a whole, e.g. for a client.
*
* @link https://make.wordpress.org/core/2023/07/14/configuring-development-mode-in-6-3/
*/
define("WP_DEVELOPMENT_MODE", "all");
/**
* Enable "Debug logging" to the '/wp-content/debug.log' file.
*
* @link https://developer.wordpress.org/advanced-administration/debug/debug-wordpress/#wp_debug_log
*/
define("WP_DEBUG_LOG", true);
/**
* Disable display of errors and warnings on the front end.
*
* Control whether debug messages (errors and warnings) are shown or not inside the HTML of pages.
*
* @link https://developer.wordpress.org/advanced-administration/debug/debug-wordpress/#wp_debug_display
*/
define("WP_DEBUG_DISPLAY", false);
@ini_set("display_errors", 0);
/**
* Use dev versions of core JS and CSS files (only needed if you are modifying these core files).
*
* @link https://developer.wordpress.org/advanced-administration/debug/debug-wordpress/#script_debug
*/
define("SCRIPT_DEBUG", true);
/**
* Enable the use of the 'Trash' for media items.
*
* @link https://wordpress.org/plugins/media-trash-button/
*/
define("MEDIA_TRASH", true);
/* That's all, stop editing! Happy publishing. */