Skip to main content
MainWP includes WP-CLI integration for managing your MainWP Dashboard, configuring MainWP Child connection authentication, and restoring built-in backups on a Child Site 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
  • How to configure MainWP Child password authentication for a WordPress user
  • How to restore a built-in backup on a Child Site from the command line
  • Example automation scripts

Prerequisites

  • MainWP Dashboard v4.1.3 or later
  • WP-CLI installed on your MainWP Dashboard server for wp mainwp commands
  • WP-CLI available on the server hosting the child site for wp mainwp-child commands
  • MainWP Child activated on the child site
  • Child sites connected to your MainWP Dashboard for Dashboard-side management commands
For more information about WP-CLI, visit the official WP-CLI documentation.

Built-In Help

WP-CLI lists every option for a command, including the ones that take a value such as --site-url, --type, --slug, --ver and --ssl_verify, with a short description and examples:
Running wp mainwp sites with no option prints a table of all child sites. The older --list and --count options still print the same table, but they are no longer listed in the help.

Sites Management

Commands for managing multiple child sites simultaneously.

List All Sites

Displays every child site in your MainWP installation.

Count All Sites

Returns the total number of child sites.

Connected Sites

Lists only child sites with active connections.

Connected Sites Count

Returns count of actively connected child sites.

Disconnected Sites

Lists child sites that are currently disconnected.

Disconnected Sites Count

Returns count of disconnected child sites.

Sync All Sites

Synchronizes data across all child sites.

Check All Sites

Verifies the status of all child sites.

Disconnect Sites

Disconnects the child sites with the given comma-separated IDs.If a site cannot be disconnected, the command prints a warning for that site and moves on to the next one. If any site failed, the command ends with Disconnect completed with errors and a non-zero exit code, so scripts can detect the failure.
Without site IDs, --disconnect-sites disconnects all of your child sites.

Example Workflows

Daily Sync Script

Create a script to sync all sites and check for updates:

Get Site Overview

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 the MainWP Dashboard server
  • MainWP Dashboard v4.1.3 or later
  • Test basic command: wp mainwp sites --all-sites
  • Site IDs identified for site-specific commands
  • WP-CLI available on the server hosting the child site before using wp mainwp-child
  • Unique Security ID configured before disabling password authentication
  • Separate backup covers the files or database affected by wp mainwp-child backup restore