Skip to main content
MainWP includes WP-CLI integration for managing your Dashboard and child sites from the command line. This enables automation, scripting, and advanced management workflows.

What You’ll Learn

  • Available WP-CLI commands for site management
  • How to sync, update, and manage sites via command line
  • Example automation scripts

Prerequisites

  • MainWP Dashboard v4.1.3 or later
  • WP-CLI installed on your Dashboard server
  • Child sites connected to your MainWP Dashboard
For more information about WP-CLI, visit the official WP-CLI documentation.

Sites Management

Commands for managing multiple child sites simultaneously.

List All Sites

wp mainwp sites --all-sites
Displays every child site in your MainWP installation.

Count All Sites

wp mainwp sites --all-sites-count
Returns the total number of child sites.

Connected Sites

wp mainwp sites --connected-sites
Lists only child sites with active connections.

Connected Sites Count

wp mainwp sites --connected-sites-count
Returns count of actively connected child sites.

Disconnected Sites

wp mainwp sites --disconnected-sites
Lists child sites that are currently disconnected.

Disconnected Sites Count

wp mainwp sites --disconnected-sites-count
Returns count of disconnected child sites.

Sync All Sites

wp mainwp sites --sync-sites
Synchronizes data across all child sites.

Check All Sites

wp mainwp sites --check-sites
Verifies the status of all child sites.

Example Workflows

Daily Sync Script

Create a script to sync all sites and check for updates:
#!/bin/bash
# daily-mainwp-sync.sh

# Sync all sites
wp mainwp sites --sync-sites

# Check for updates
wp mainwp updates --available-updates

# Check site status
wp mainwp sites --check-sites

Get Site Overview

# Get all connected sites
wp mainwp sites --connected-sites

# For each site, get available updates
wp mainwp site --site-available-updates 1
wp mainwp site --site-available-updates 2
Replace site IDs with your actual child site IDs. You can find site IDs by running wp mainwp sites --all-sites.

Self-Check Checklist

  • WP-CLI installed on Dashboard server
  • MainWP Dashboard v4.1.3 or later
  • Test basic command: wp mainwp sites --all-sites
  • Site IDs identified for site-specific commands