Using WP-CLI: Administer WordPress from the Command Line
What Will You Learn in This Guide?
In this guide, you will learn to manage WordPress without opening a panel using WP-CLI.
The goal is to gain speed and provide automation.
🧠 Technical Summary
Main topic: Managing WordPress with WP-CLI
Problem solved: Panel dependency and slow maintenance processes
Scope: Installation, plugin, theme, content, database and core management
Prerequisites
- Sudo authorized, non-root SSH user
- Server with LAMP stack installed
- A working WordPress installation
1️⃣ WP-CLI Installation
- WP-CLI is distributed as a PHP-based Phar file.
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
- This command downloads the WP-CLI file.
php wp-cli.phar --info
- Checks that the installation is working correctly.
chmod +x wp-cli.phar
sudo mv wp-cli.phar /usr/local/bin/wp
- Makes WP-CLI available system-wide.
wp cli version
- Shows the installed WP-CLI version.
2️⃣ Plugin Management
- Enter the WordPress directory:
cd /var/www/ornek.com/html
- List Plugins
wp plugin list
- Shows installed plugins and their status.
- Plugin Search
wp plugin search seo
- Searches the WordPress plugin repository.
- Installation and Activation
wp plugin install all-in-one-seo-pack --activate
- Installs and activates the plugin.
wp plugin update --all
- Updates all plugins.
wp plugin delete contact-form-7
- Deletes the plugin completely.
3️⃣ Theme Management
wp theme list
- Lists installed themes.
wp theme install colormag --activate
- Installs and activates the theme.
wp theme update --all
- Updates all themes.
4️⃣ Content Creation
wp post create --post_title="WP-CLI ile İlk Yazı" --post_status=publish --edit
- Creates a new post and opens it in the editor.
wp post create --post_type=page --post_title="Hakkımızda" --post_status=draft
- Creates a draft page.
- Creating Fake Content
wp post generate --count=50
- Automatically generates content for testing.
- Revision Cleanup
wp post delete $(wp post list --post_type=revision --format=ids) --force
- Deletes all old post revisions.
5️⃣ Database Operations
- Backup
wp db export
- Backs up the entire database as SQL file.
- Search and Replace
wp search-replace 'eski-domain.com' 'yeni-domain.com' --dry-run
- Previews changes.
wp search-replace 'eski-domain.com' 'yeni-domain.com' --skip-columns=guid
- Applies changes without touching the GUID field.
6️⃣ WordPress Core Update
wp core version
- Shows the current WordPress version.
wp core check-update
- Checks for updates.
wp core update
- Upgrades WordPress to the latest version.
❓ Frequently Asked Questions (FAQ)
1. Will WP-CLI replace the panel? No, but it is much faster for batch operations.
2. Does it work on shared hosting? Yes, if there is SSH access.
3. Will the wrong command break the site? Yes, that's why a backup is a must.
4. How do I see all the options of the commands? You can use wp help command.
5. Is it possible to install WordPress from scratch with WP-CLI? Yes, it is possible with wp core install.
🚀 Result
WP-CLI is the indispensable tool of professional WordPress administrators. Provides speed, automation and control.
You can immediately publish your WP-CLI and WordPress projects on GenixNode's developer-friendly servers.

