wp cli cheat sheet, czyli ściąga

Instalacja wp-cli

curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
chmod +x wp-cli.phar
mv wp-cli.phar /usr/local/bin/wp
wp --info

MySQL tworzenie bazy i usera:

create database DBNAME;
grant all on DBNAME.* to 'DBUSER'@'localhost' identified by 'DBPASS';
flush privileges;

Instalacja WordPress w 5 minut

wp core download
wp core config --dbname=$DBNAME --dbuser=$DBUSER --dbpass=$DBPASS
wp core install --url=DOMENA --title='Awesome Site' --admin_user=USER \
--admin_password=hasło --admin_email=email@gmail.com

Zaraz po zainstalowaniu WordPressa

wp plugin delete akismet hello
wp theme install generatepress --activate
wp theme delete twentyfourteen twentythirteen twentytwelve
wp post delete $(wp post list --post_type='post' --format=ids)
wp post delete $(wp post list --post_type='page' --format=ids)
wp widget delete $(wp widget list sidebar-1 --format=ids)
wp option set default_comment_status closed    

Tworzenie stron

wp post create --post_type=page --post_status=publish --post_title='Home'
wp post create --post_type=page --post_status=publish --post_title='O stronie'
wp post create --post_type=page --post_status=publish --post_title='Kontakt'

Permalinki

# Nazwa posta
wp rewrite structure '/%postname%/' --hard
# domyślne
wp option update permalink_structure ""

Zmiana opisu strony

wp option update blogdescription "Moja nowa super strona"

Zmiana URL strony

wp option update siteurl http://mynewurl.com
wp option update home http://mynewurl.com

Listowanie postów, stron, CCT

wp post list
wp post list --post_type='page'
wp post list --post_type='customcontenttype'

Userzy, zmiana hasła usera

wp user list 
wp user update USERNAME --user_pass="PASSWORD"

Szybki backup plików i bazy

tar -czf "../$(date '+%F')_nazwa.tar.gz" . 
wp db export "../$(date '+%F')_nazwa.sql"

Generowanie motywu potomnego (child-theme)

wp scaffold child-theme nazwa_motywu --parent_theme=generatepress