Tag: multisite

Converting All Sites on a WordPress Multisite to HTTPS with WP-CLI

I had a need to convert an entire WordPress multisite from HTTP to HTTPS. I wanted to narrowly scope my WP-CLI command to avoid converting all http:// links to https:// and instead only find and replace the domains of the sites in my multisite. With WP-CLI, this ended up being a pretty simple script:

#!/bin/bash

# Some Bash options
set +x
set -euo pipefail

# Change to the directory of the WordPress multisite install
cd /var/www/wp-install-directory

# Extract all domains hosted in this multisite
for domain in $(wp site list --field=domain)
do
        # Search and replace each domain across 
        # all tables in the multisite with the
        # https equivalent
        wp search-replace http://${domain} https://${domain} --all-tables
done