Quick mysql notes

 mysql -u myawesomeusername -p
 mysql> create database thisismy_databasename;
 mysql> grant all on thisismy_databasename.* to 'thisismy_username' identified by 'ApasswordBetterThanThis';

In a nutshell

(copy and run after successfully running wp core config and wp core install)

 wp plugin delete akismet hello;
 wp theme activate twentytwelve;
 wp theme delete twentyfourteen twentythirteen;
 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;

WP-CLI

 

Pete here.  As you may or may not know WordPress is a great tool to create many things on the web.  A great tool to use with WordPress is wp-cli (wp-cli.org).  Save some time.

This assumes you have installed wp-cli and are familiar with the command line.  There are many great tutorials out there on wp-cli installation and beginner use.  I have simply compiled a list of commands I often use.

DOWNLOAD AND INSTALL WORDPRESS
(5min installs are so 2013…)
wp core download
wp core config --dbname=my_databasename --dbuser=my_databaseuser --dbpass=password
wp core install --url=mysite.com --title='Awesome Site' --admin_user=mydesiredusername1 --admin_password=changemepass [email protected]
DELETE PLUGINS AND THEMES
(Why keep what you don’t use?)
wp plugin delete akismet hello
wp theme delete twentyfourteen twentythirteen
DELETE ALL POSTS:
(good for when setting up an new site to quickly delete hello word fluff)
wp post delete $(wp post list --post_type='post' --format=ids)
DELETE ALL PAGES:
(good for when setting up an new site to quickly delete hello word fluff)
wp post delete $(wp post list --post_type='page' --format=ids)
REMOVE WIDGETS FROM SIDEBAR:
(sidebar-1 is default for wordpress twentytwelve, twentythriteen and twentyfourteen)
wp widget delete $(wp widget list sidebar-1 --format=ids)
CHANGE DESCRIPTION
(no my site is not ‘Just another WordPress site’)
wp option update blogdescription "One of a kind epic tagline for my one of a kind epic site"
TURN OF COMMENTS BY DEFAULT
(must be done before page creation to apply to the new pages)
 wp option set default_comment_status closed
CREATE A PAGE
(Pretty static here…)
wp post create --post_type=page --post_status=publish --post_title='About'
Pages everyone loves:
wp post create --post_type=page --post_status=publish --post_title='Home'
wp post create --post_type=page --post_status=publish --post_title='About'
wp post create --post_type=page --post_status=publish --post_title='Contact'
Get fancy and do it all at once:
wp post create --post_type=page --post_status=publish --post_title='Home' &&
wp post create --post_type=page --post_status=publish --post_title='About' &&
wp post create --post_type=page --post_status=publish --post_title='Contact'
CREATE A POST
(We like change…)
wp post create --post_type=post --post_status=publish --post_title='The meaning of life...'
LIST ALL POSTS (OR PAGES OR ANY OTHER CONTENT TYPE)
(as shown before)
wp post list
wp post list --post_type='page'
wp post list --post_type='customcontenttype'
SET FRONT PAGE AND POSTS PAGE
(Home page ID is 5, Blog page ID is 10)
wp option update page_on_front 5
wp option update page_for_posts 10
wp option update show_on_front page
CHANGE THE SITE URL
wp option update siteurl http://mynewurl.com
wp option update home http://mynewurl.com
PERMALINKS
SET TO DEFAULT
wp option update permalink_structure ""
SET TO POST NAME
wp rewrite structure '/%postname%/' --hard

 

 

Changing file permissions

Owner

chown -R username target-directory/

Group

chgrp -R servergroupname target-directory/

Directories

find /path/to/your/wordpress/install/ -type d -exec chmod 755 {} ;

Files

find /path/to/your/wordpress/install/ -type f -exec chmod 644 {} ;

 

Migrate Sites w/ WP-CLI

On old server

In WordPress directory export the db:

wp export

On new server

Send the file to the new server

scp [email protected]:~/wordpres-directory/my-sql-dump-file-name.sql ~/public/
wp import

Move sites folder