Skip to main content

Site Management

Overview

wp site commands are the operational core of WordPress multisite. Use them to create, list, update, archive, and delete subsites quickly and safely across a network.

Understanding Site Lifecycle Management

A multisite network is easiest to run when you treat sites as lifecycle-managed resources:

  • Provision new sites with consistent naming
  • Audit status and activity with structured output
  • Update metadata and visibility settings
  • Archive/Deactivate unused sites before deletion
  • Delete only when retention policies allow it

Creating and Listing Sites

Create a New Subsite

# Create subsite (subdirectory or subdomain based on network mode)
wp site create --slug=client1 --title="Client 1 Site" --email=client1@example.com

Example output:

Success: Site 3 created: http://example.com/client1/

Create Site in Specific Network

# Useful for multi-network installations
wp site create --network_id=2 --slug=projectx --title="Project X" --email=ops@example.com

List All Sites

# Default table output
wp site list

# Show selected fields
wp site list --fields=blog_id,url,registered,last_updated,public,archived

List Sites in JSON for Automation

wp site list --format=json

Use this with monitoring jobs, dashboards, or scheduled audits.

Updating Site State

Mark a Site as Archived or Public

# Archive site ID 7
wp site archive 7

# Unarchive site ID 7
wp site unarchive 7

# Mark site as public
wp site public 7

# Mark site as private
wp site private 7

Mark a Site as Spam or Deactivate It

# Deactivate site access
wp site deactivate 9

# Re-activate site access
wp site activate 9

# Mark as spam
wp site spam 10

# Remove spam flag
wp site unspam 10

These states are useful for governance workflows without immediately deleting data.

Deleting Sites Safely

Delete a Site

# Permanently delete site by ID
wp site delete 12 --yes
Destructive Action

wp site delete is permanent. Export content and confirm retention requirements first.

Safety Workflow Before Deletion

# 1) Check site details
wp site list --fields=blog_id,url,registered,last_updated --format=table

# 2) Optional content export from target URL context
wp export --url=client12.example.com --dir=exports/

# 3) Delete site
wp site delete 12 --yes

Query Patterns for Operations Teams

Get Only URLs

wp site list --field=url

Count Total Sites

wp site list --format=count

Batch Action Across Sites

# Example: list plugin status on every site
for url in $(wp site list --field=url); do
echo "Checking $url"
wp plugin list --url="$url" --fields=name,status,update
done

Real-World Scenarios

Scenario 1: Agency Site Provisioning

#!/bin/bash
# provision-client-site.sh

CLIENT_SLUG="$1"
CLIENT_TITLE="$2"
CLIENT_EMAIL="$3"

wp site create --slug="$CLIENT_SLUG" --title="$CLIENT_TITLE" --email="$CLIENT_EMAIL"

Scenario 2: Quarterly Network Audit

wp site list --fields=blog_id,url,registered,last_updated,public,archived --format=csv > multisite-audit.csv

Scenario 3: Archive Dormant Sites Before Cleanup

# Example manual process for selected site IDs
wp site archive 21
wp site archive 24
wp site archive 30

Best Practices

1. Use Naming Standards for Slugs

Prefer predictable patterns such as client-acme, dept-hr, or tenant-001.

2. Prefer Structured Output for Tooling

wp site list --format=json

3. Archive Before Delete

Archive and observe for a retention period before permanent deletion.

4. Keep an Audit Trail

Record who created, archived, or deleted each site in change logs.

5. Automate Repetitive Admin Tasks

Use cron and scripts for status reports, plugin checks, and governance tasks.

Troubleshooting

Site Creation Fails

# Confirm multisite mode is active
wp eval 'echo is_multisite() ? "true" : "false";'

# Check if slug or domain already exists
wp site list --fields=blog_id,url

Cannot Delete Site

# Verify target site ID
wp site list --fields=blog_id,url

# Retry with confirmation flag
wp site delete <site-id> --yes

Command Works on Main Site but Not Subsites

Use explicit URL context when running site-level commands:

wp option get blogname --url=client1.example.com

Quick Reference

Essential Commands

# Create and list
wp site create --slug=<slug> --title="<title>" --email=<email>
wp site create --network_id=<id> --slug=<slug> --title="<title>" --email=<email>
wp site list
wp site list --format=json
wp site list --field=url

# State management
wp site archive <site-id>
wp site unarchive <site-id>
wp site deactivate <site-id>
wp site activate <site-id>
wp site public <site-id>
wp site private <site-id>
wp site spam <site-id>
wp site unspam <site-id>

# Delete
wp site delete <site-id> --yes

Comparison: Common Site Operations

OperationCommandBest Use Case
Provision Sitewp site create ...New tenant/client onboarding
Network Inventorywp site listOperational audit and reporting
Soft Retirementwp site archive IDRetention period before removal
Permanent Removalwp site delete ID --yesDecommissioned sites
Automation Exportwp site list --format=jsonDashboards and scripts
Key Takeaway

Use wp site for full site lifecycle management: provision, govern, and decommission with repeatable CLI workflows.

Next Steps