Skip to content
  • Home
  • About
  • No Access
  • Privacy Policy
Bits of .NET
Bits of .NET
  • Asp.Net Core
  • C#
  • SQL
  • JavaScript
  • CSS
  • About
  • ErcanOPAK.com
  • No Access
  • Privacy Policy

Bits of .NET

Daily micro-tips for C#, SQL, performance, and scalable backend engineering.

  • Asp.Net Core
  • C#
  • SQL
  • JavaScript
  • CSS
  • About
  • ErcanOPAK.com
  • No Access
  • Privacy Policy
Wordpress

WordPress: Use WP-CLI for Command-Line Site Management

- 30.03.26 - ErcanOPAK

⚡ Manage WordPress from Terminal

Clicking through admin for every site update? Slow. WP-CLI lets you install plugins, update core, manage users—all from command line. 10x faster.

Install WP-CLI

# Download
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar

# Make executable
chmod +x wp-cli.phar

# Move to PATH
sudo mv wp-cli.phar /usr/local/bin/wp

# Test
wp --info

🚀 Essential Commands

# Update WordPress core
wp core update

# Install plugin
wp plugin install contact-form-7 --activate

# Update all plugins
wp plugin update --all

# Install theme
wp theme install twentytwentyfour --activate

# Create user
wp user create john john@example.com --role=editor

# Search & replace in database
wp search-replace 'http://oldsite.com' 'https://newsite.com'

# Export database
wp db export backup.sql

# Import database
wp db import backup.sql

# Clear cache
wp cache flush

# Generate posts for testing
wp post generate --count=100

Real-World: Bulk Site Management

📦 Update 50 Sites Script

#!/bin/bash

sites=(
  "/var/www/site1"
  "/var/www/site2"
  "/var/www/site3"
  # ... 47 more
)

for site in "${sites[@]}"; do
  echo "Updating $site"
  cd "$site"
  
  # Backup first
  wp db export "backup-$(date +%Y%m%d).sql"
  
  # Update everything
  wp core update
  wp plugin update --all
  wp theme update --all
  
  echo "✓ $site updated"
done

# 50 sites updated in 10 minutes instead of 5 hours

Migration Made Easy

# On old server
wp db export oldsite.sql
wp media regenerate --yes  # Regenerate thumbnails

# Transfer files + database to new server
scp -r wp-content/ user@newserver:/var/www/html/
scp oldsite.sql user@newserver:/tmp/

# On new server
wp db import /tmp/oldsite.sql
wp search-replace 'http://oldsite.com' 'https://newsite.com'
wp search-replace '/old/path' '/new/path'
wp cache flush

# Done! Site migrated

✅ Power User Commands

  • wp post list: List all posts with filters
  • wp media regenerate: Regenerate all image sizes
  • wp user list: Show all users with roles
  • wp option get siteurl: Get any option value
  • wp plugin list –status=inactive: Find unused plugins
  • wp transient delete –all: Clear all transients

💡 Cheat Sheet

Task Command
Update core wp core update
Install plugin wp plugin install [name] --activate
Backup DB wp db export backup.sql
Search/Replace wp search-replace 'old' 'new'
Clear cache wp cache flush

“Manage 30 client sites. Before WP-CLI: 2 hours to update everything. After: Created bash script with WP-CLI. 10 minutes, all sites updated, backed up, tested. Game changer.”

— WordPress Agency Owner

Related posts:

WordPress Slow First Load — Autoloaded Options Table

WordPress Slow First Load — Autoloaded Options Table

WordPress: Fix a Custom Post Type That Disappears From the Admin Menu After an Update

WordPress: Fix a Custom Post Type That Disappears From the Admin Menu After an Update

Wordpress: Fix a Navigation Block Losing Submenu Items After Sync

WordPress: Fix a Navigation Block Losing Submenu Items After Sync

Views: 14

Post navigation

Photoshop: Convert to Smart Objects for Non-Destructive Editing
WordPress: Use REST API to Build Headless WordPress Applications

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

November 2026
M T W T F S S
 1
2345678
9101112131415
16171819202122
23242526272829
30  
« Oct    

Most Viewed Posts

  • How to make theater mode the default for Youtube (1,068)
  • Get the User Name and Domain Name from an Email Address in SQL (990)
  • How to add default value for Entity Framework migrations for DateTime and Bool (986)
  • Get the First and Last Word from a String or Sentence in SQL (865)
  • How to select distinct rows in a datatable in C# (859)
  • How to enable, disable and check if Service Broker is enabled on a database in SQL Server (661)
  • Add Constraint to SQL Table to ensure email contains @ (619)
  • Average of all values in a column that are not zero in SQL (577)
  • How to use Map Mode for Vertical Scroll Mode in Visual Studio (553)
  • Find numbers with more than two decimal places in SQL (481)

Recent Posts

  • Network Speed Monitor Windows Application v2.5.1
  • Ağ Hızı İzleyici Windows Uygulaması v2.5.1
  • How to make theater mode the default for Youtube
  • The AI Prompt That Audits a Function for Thread-Safety Gaps
  • Ajax: Fix a Fetch Request Caching a Response Despite No-Store
  • WordPress: Fix a Navigation Block Losing Submenu Items After Sync
  • Visual Studio: Fix CodeLens Reference Counts Stuck at Stale Numbers
  • C#: Fix a UTF-8 String Literal Behaving Differently in a Switch
  • Photoshop: Fix a Liquify Mesh Snapping Back on a Smart Object
  • The AI Prompt That Turns a Crash Dump Into a Short Repro Script

Most Viewed Posts

  • How to make theater mode the default for Youtube (1,068)
  • Get the User Name and Domain Name from an Email Address in SQL (990)
  • How to add default value for Entity Framework migrations for DateTime and Bool (986)
  • Get the First and Last Word from a String or Sentence in SQL (865)
  • How to select distinct rows in a datatable in C# (859)

Recent Posts

  • Network Speed Monitor Windows Application v2.5.1
  • Ağ Hızı İzleyici Windows Uygulaması v2.5.1
  • How to make theater mode the default for Youtube
  • The AI Prompt That Audits a Function for Thread-Safety Gaps
  • Ajax: Fix a Fetch Request Caching a Response Despite No-Store

Social

  • ErcanOPAK.com
  • GoodReads
  • LetterBoxD
  • Linkedin
  • The Blog
  • Twitter
© 2026 Bits of .NET | Built with Xblog Plus free WordPress theme by wpthemespace.com