
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 --infowp core versionwp core downloadwp config create \
--dbname=namadb \
--dbuser=user \
--dbpass=pass \
--dbhost=127.0.0.1wp core install \
--url="https://site.com" \
--title="Judul" \
--admin_user=admin \
--admin_password=pass \
--admin_email=email@site.comwp db createwp db export backup.sqlwp db import backup.sqlwp search-replace "https://lama.com" "https://baru.com"wp plugin listwp plugin install woocommerce --activatewp plugin activate nama-pluginwp plugin deactivate nama-pluginwp plugin update --allwp theme listwp theme install generatepress --activatewp theme update --allwp user listwp user create nama email@site.com --role=administrator --user_pass=passwp user update admin --user_pass=passbaruwp post listwp post create --post_title="Judul" --post_status=draftwp post update 123 --post_status=publishwp option get siteurl
wp option get homewp option update siteurl "https://baru.com"
wp option update home "https://baru.com"Jika pakai plugin cache:
wp cache flushJika pakai Nginx FastCGI:
rm -rf /var/cache/nginx/*
systemctl restart nginxwp --infowp config set WP_DEBUG true --rawwp config set WP_DEBUG false --rawJika error:
mysql: No such file or directory<br>→ Pastikan PATH MySQL benar:
export PATH=/usr/local/mysql/bin:$PATHAtau jika di WSL:
Gunakan --dbhost=127.0.0.1.
wp core update
wp plugin update --all
wp theme update --allwp media regeneratewp db export staging.sql<br>
scp staging.sql user@server:/home/site<br>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 flushWP-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.