
WP-CLI adalah tool command line untuk mengelola WordPress tanpa masuk dashboard. Cepat, efisien, dan wajib untuk developer yang bekerja di server, VPS, atau local development.
Artikel ini merangkum semua perintah inti yang paling sering dipakai, lengkap dengan contoh real yang langsung bisa digunakan.
Instalasi (Linux/Mac):
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
php wp-cli.phar --info
chmod +x wp-cli.phar
sudo mv wp-cli.phar /usr/local/bin/wpTest:
wp --info
wp core version
wp core download
wp config create \
--dbname=namadb \
--dbuser=user \
--dbpass=pass \
--dbhost=127.0.0.1
wp core install \
--url="https://site.com" \
--title="Judul" \
--admin_user=admin \
--admin_password=pass \
[email protected]
wp db create
wp db export backup.sql
wp db import backup.sql
wp search-replace "https://lama.com" "https://baru.com"
wp plugin list
wp plugin install woocommerce --activate
wp plugin activate nama-plugin
wp plugin deactivate nama-plugin
wp plugin update --all
wp theme list
wp theme install generatepress --activate
wp theme update --all
wp user list
wp user create nama [email protected] --role=administrator --user_pass=pass
wp user update admin --user_pass=passbaru
wp post list
wp post create --post_title="Judul" --post_status=draft
wp post update 123 --post_status=publish
wp option get siteurl
wp option get home
wp option update siteurl "https://baru.com"
wp option update home "https://baru.com"
Jika pakai plugin cache:
wp cache flush
Jika pakai Nginx FastCGI:
rm -rf /var/cache/nginx/*
systemctl restart nginx
wp --info
wp config set WP_DEBUG true --raw
wp config set WP_DEBUG false --raw
Jika error:
mysql: No such file or directory
→ Pastikan PATH MySQL benar:
export PATH=/usr/local/mysql/bin:$PATH
Atau jika di WSL:
Gunakan --dbhost=127.0.0.1.
wp core update
wp plugin update --all
wp theme update --all
wp media regenerate
wp db export staging.sql
scp staging.sql user@server:/home/site
Ini format migrasi cepat yang biasa dipakai di VPS:
wp db export before.sql
wp search-replace "https://domainlama.com" "https://domainbaru.com"
wp option update siteurl "https://domainbaru.com"
wp option update home "https://domainbaru.com"
wp cache flush
| Kebutuhan | Command |
|---|---|
| Install WP | wp core download |
| Setup config | wp config create |
| Install | wp core install |
| Export DB | wp db export |
| Import DB | wp db import |
| Migrasi URL | wp search-replace |
| Install plugin | wp plugin install |
| Update plugin | wp plugin update --all |
| Buat user admin | wp user create ... |
| Cek database error | wp --info |
WP-CLI mempercepat workflow developer WordPress secara drastis: instalasi lebih cepat, migrasi lebih rapi, debugging lebih mudah, dan otomatisasi bisa dilakukan dalam beberapa detik.
Jika kamu bekerja di VPS, WP-CLI bukan tambahan — ini kebutuhan.