Skip to content

Instantly share code, notes, and snippets.

@allysonsouza
Last active July 26, 2024 18:32
Show Gist options
  • Save allysonsouza/cad1d8273ba4ca0a167ee40d3f195640 to your computer and use it in GitHub Desktop.
Save allysonsouza/cad1d8273ba4ca0a167ee40d3f195640 to your computer and use it in GitHub Desktop.
[WP-CLI Commands] Useful WP-CLI commands and "recipes" #wpcli #wordpress

Multisite Search and Replace

wp config set DOMAIN_CURRENT_SITE "newdomain.com"
wp search-replace "olddomain.com" "newdomain.com" --url=newdomain --precise
wp search-replace --network "http://olddomain.com" "https://newdomain.com" --precise --all-tables

Add Super Admin

wp user create username [email protected] --role=administrator
wp super-admin add username

WooCommerce - Delete all products

wp post delete $(wp post list --post_status=trash --post_type='product' --format=ids --posts_per_page=10000) --force

List installed plugins as composer.json dependencies syntax

$ wp plugin list --format=csv --fields=name,version | awk '{if ($1 != "name,version") print $1;}' | awk -F',' '{print "\"wpackagist-plugins/" $1 "\":" " \"" $2 "\","}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment