Skip to content

Instantly share code, notes, and snippets.

@samstoller
samstoller / 01-walkthrough.md
Last active October 18, 2018 06:32
How to use wp-cli with a non-standard wp-config.php location

You are running a customized WordPress install where your configurations are NOT located in one of the two required locations (outside the webroot for example) and are receving the following error when running wp-cli commands:

Error: Strange wp-config.php file: wp-settings.php is not loaded directly.

###Solution Simply move the require_once ... wp-settings.php line from the actual configuration file to the end of file that is requiring/including it. See below for examples.

This works by tricking the wp-cli regex into correctly parsing the configuration files.

@samstoller
samstoller / wp_installer.sh
Last active April 3, 2020 03:53
WordPress install as git submodule
# Create the basic site structure
# Web server points to public/ keeping configuration outside of webroot
$ mkdir site && cd site
$ mkdir conf/ public/
# Init repo
$ git init && git add . && git commit -m 'Init commit'
# Install WP as submodule to public/
$ git submodule add git://github.com/WordPress/WordPress.git public/wp-core