Monday, June 20, 2016

Get activated theme on every site in WordPress Multisite using wp-cli

You can use this:

1. Install wp-cli.

2. Create a bash script (export_blog_theme.sh) with the following content

#! /bin/bash

for url in $(wp site list --field=url --path=/path/to/your/wordpress/root)
do
        theme=$(wp option get template --url="$url" --path=/path/to/your/wordpress/root)
        echo "$url,$theme"
done


3. Make script executable:

$ sudo chmod +x export_blog_theme.sh

4. Run the script:

$ sudo -u www-data ./export_blog_theme.sh > blog_theme_list.csv


Notes: Sometimes, the script return no result because of caches or WordPress db connection limitation.