Created: 2021-02-16
Updated: 2023-09-20
These examples assume a working local WP-CLI helper –
for installing and file structure advice, see 4.2) installing WP-CLI.
Assumes an existing local database and host.
# root dir is project dir
mkdir -p wordpress
cd wordpress
# download to current folder, see
# https://developer.wordpress.org/cli/commands/core/download/
wp core download --locale=en_GB
# TODO: using the password on the shell is not ideal, see
# https://developer.wordpress.org/cli/commands/config/create/#examples
wp config create --dbname=[name] --dbuser=[user] --dbpass=[pass]
# this will return a user password
wp core install --url=website.local --title="Website title" --admin_user="janitor" --admin_email="foo@bar.local"
# create local wp-cli config for htaccess generation, see
# https://developer.wordpress.org/cli/commands/rewrite/structure/
printf "apache_modules:\n\
- mod_rewrite\n" >> ../wp-cli.local.yml
# create htaccess
wp rewrite structure '/%year%/%monthnum%/%postname%/' --hard
TODO: add SQLite example
wp db reset --yes
gunzip [file.sql.gz] --stdout | wp db import -
# reset pw of user `admin` to `test`
wp eval "wp_set_password( 'test', get_user_by( 'login', 'admin' )->ID );"
# set local url
# needs http[s]:// protocol and quotes
wp option update siteurl 'http://domain.local'
wp option update home 'http://domain.local'
# flush redirects
wp rewrite flush
# update core
wp core update
# update all themes
wp theme update --all
# update all plugins
wp plugin update --all
# update language
wp language core update
wp language plugin --all update
wp language theme --all update
# update db scheme
# otherwise, an admin user will be prompted
wp core update-db
Note: paradoxically, a working wp-config.php
is mandatory for WP-CLI to work. You can use the helper command wp config create
if you don't want to clone wp-config-sample.php
manually.
wp core update --version=5.4 --locale=en_GB
Check locale availability via WP translation platform
You can
or
/bin/wp-cli.phar
which makes sure each script continues to work on a remote installation.
# grab and unpack the latest locale-specific release
curl https://de.wordpress.org/latest-en_GB.tar.gz -o latest-en_GB.tar.gz
tar -xvzf latest-en_GB.tar.gz
cd wordpress
--allow-root
: php - Setting WordPress siteurl using wp-cli with WAMP virtual host - Stack Overflow👉 Found an error or have a proposition?
Contact me via mail below – thanks!
--
Cover image: U.S. National Archives, via New Old Stock