Skip to content

Instantly share code, notes, and snippets.

@dikiyforester
Last active May 24, 2018 07:24
Show Gist options
  • Save dikiyforester/0a0da49ceabf616227943229451a1e3b to your computer and use it in GitHub Desktop.
Save dikiyforester/0a0da49ceabf616227943229451a1e3b to your computer and use it in GitHub Desktop.
Bash script to create a new fresh WordPress site install within a network (using wp cli)
#!/bin/bash
if [ $# -lt 1 ]; then
echo "usage: $(basename $0) <new-site-slug> [<theme-slug>, <plugin-slug>]"
exit 1
fi
wp site delete --slug="$1"
wp site create --slug="$1"
if [ $# -ge 1 ]; then
wp theme activate "$2" --url="http://wp.home/$1"
fi
if [ $# -ge 2 ]; then
wp plugin activate "$3" --url="http://wp.home/$1"
fi
@dikiyforester
Copy link
Author

Where http://wp.home/ is the network URL

Usage:

$ wpnew cp-new classipress critic

It will re-install new site with cp-new slug and activate classipress theme with critic plugin

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment