## ## ######## ###### ## ####
## # ## ## ## ## ## ## ##
## ### ## ## ## ## ## ##
## ## ## ## ######## ### ## ## ##
#### #### ## ## ## ##
### ### ## ## ## ## ##
## ## ## ###### ######## ####
# Your WordPress Command Line Interface Guide
# (╯°□°)╯ ︵ ┻━┻
# /[][][]\ 💻
# | | |
# /\ /\
######################################
# Connecting to WP-CLI
# Most web hosts provide SSH access.
# Log in to your server via SSH using the terminal or an SSH client.
# Once connected, go to your WordPress root, for example:
cd /path/to/wordpress
######################################
# Initial WordPress install
wp core download
wp config create --dbname=your_db_name --dbuser=your_db_user --dbpass=your_db_password --dbhost=localhost
wp db create
wp core install --url=YOUR_DOMAIN.com --title="SITE TITLE" --admin_user=ADMIN_USER --admin_password=ADMIN_P4SS --admin_email=YOUR@EMAIL.com
wp option update siteurl "https://example.com"
wp option update home "https://example.com"
######################################
# Main settings
wp option update blog_public 1 # site visible to search engines
wp option update blogname "Your site name" # sets the site title
wp option update blogdescription "Your site description"
wp option update default_ping_status closed # disables pings and trackbacks
wp option update date_format "F j, Y"
wp option update time_format "g:i a"
wp option update timezone_string "America/New_York"
wp option update start_of_week 1 # 0 for Sunday, 1 for Monday, etc.
wp rewrite structure '/%postname%/' --hard # update permalinks and rewrite the .htaccess file
######################################
# Site cleanup
wp site empty --uploads # delete all posts, pages, comments, and uploads folder contents
wp site empty # same, sans ditching the uploads
wp post delete $(wp post list --post_type='post' --format=ids) # delete all posts
wp post delete $(wp post list --post_type='page' --format=ids) # delete all pages
wp comment delete $(wp comment list --format=ids) # delete all comments
######################################
# Plugins and themes
wp plugin install advanced-custom-fields code-snippets redirection --activate
wp plugin activate plugin-slug
wp plugin deactivate plugin-slug
wp plugin delete hello
wp plugin delete $(wp plugin list --status=inactive --field=name)
wp plugin delete --all
wp theme install neve-fse --activate
wp theme delete $(wp theme list --status=inactive --field=name)
######################################
# Diagnostics
wp config get
wp config path
wp db size --tables
######################################
# Maintenance
wp core update
wp plugin update --all
wp plugin status
wp db optimize # runs an SQL OPTIMIZE TABLE operation on all tables in the database.
wp comment delete $(wp comment list --status=spam --format=ids) # delete all spam comments
wp cron event run --due-now # trigger all scheduled cron events that are due now
######################################
# Users
wp user create author_username author@example.com --role=author --user_pass=yourpassword
wp user create editor_username editor@example.com --role=editor --user_pass=yourpassword
wp user update adminuser@example.com --user_pass=new-password-example # reset user password
######################################
# Main pages and dummy posts
wp post create --post_content="$(cat about.txt)" --post_type=page --post_title='About Us'
wp post create --post_content="<p>This is some template content for the about page.</p> $(curl -s http://loripsum.net/api/2)" --post_type=page --post_title='About Us'
wp post create --post_content="$(cat contact.txt)" --post_type=page --post_title='Contact'
wp post create --post_content="<p>You can reach us via email at contact@example.com or phone at (555) 123-4567.</p> $(curl -s http://loripsum.net/api/2)" --post_type=page --post_title='Contact'
wp post create --post_title="Example Post" --post_content="$(curl -s http://loripsum.net/api/6)" --post_status=publish
wp post create --post_title="$(curl -s 'https://random-word-api.herokuapp.com/word?number=2' | sed 's/[][]//g; s/","/ /g; s/"//g')" --post_content="$(curl -s http://loripsum.net/api/6)" --post_status=publish
######################################
# COMPLETE STACK
wp site empty
wp option update blog_public 1
wp option update blogname "Your site name"
wp option update default_ping_status closed
wp option update timezone_string "America/New_York"
wp rewrite structure '/%postname%/' --hard
wp plugin delete hello
wp plugin install wp-seopress advanced-custom-fields code-snippets admin-site-enhancements optimole-wp redirection --activate
wp theme install neve-fse --activate
wp user create editor_username editor@example.com --role=editor --user_pass=yourpassword
wp post create --post_content="$(cat about.txt)" --post_type=page --post_title='About Us'
wp post create --post_content="$(cat contact.txt)" --post_type=page --post_title='Contact'
wp post create --post_title="$(curl -s 'https://random-word-api.herokuapp.com/word?number=2' | sed 's/[][]//g; s/","/ /g; s/"//g')" --post_content="$(curl -s http://loripsum.net/api/6)" --post_status=publishLearn the Main WP-CLI Commands
In
