Command Line WordPress with WP-CLI
-
Upload
james-collins -
Category
Technology
-
view
128 -
download
0
description
Transcript of Command Line WordPress with WP-CLI
Command Line WordPress with WP-CLI
James Collins
@om4jameshttp://jamesc.id.au/
WordPress Melbourne User Group - September 2013
What is WP-CLI?
A command line tool for managing WordPress installations
Uses the command line (not a web browser)
http://wp-cli.org/
2
Why?
(Usually) faster than using a mouse
Powerful - automate/script common tasks
Useful when managing lots of WordPress installations (including Multisite)
Active project with over 60 contributors
3
Usage
Install WP-CLI once on your computer/server
Navigate to a WordPress install:
cd /path/to/wordpress/install/
Run the ‘wp’ command:wp
4
What Can It Do?
5
WordPress Core
Update WordPress core:
wp core update
Upgrade WordPress database:
wp core update-db
6
WordPress Plugins
Update all plugins:
wp plugin update-all
List all plugins:
wp plugin status
I = Inactive, A = Active, M = Must Use, U = Update Available
7
WordPress Plugins (cont.)
Install a plugin from WordPress.org:
wp plugin install facebook
Activate a plugin:
wp plugin activate facebook
or:
wp plugin install --activate facebook
8
WordPress Themes
Update all themes:
wp theme update-all
List all themes:
wp theme status
I = Inactive, A = Active, U = Update Available
9
WordPress Themes (cont.)
Install a theme from WordPress.org:
wp plugin install quark
Activate a theme:
wp theme activate quark
or:
wp theme install --activate quark
10
Update Everything!
Update WordPress, plugins & themes:
wp core update && wp plugin update-all && wp theme update-all
Use this in a daily cron job (if you dare)
11
Database Search/Replace
Search/replace in all tables in the database
Will correctly handle serialized values
Useful when changing domain names
wp search-replace 'http://example.dev' 'http://example.com' --dry-run
12
WordPress Media/Uploads
Regenerate/recreate WordPress thumbnails:
wp media regenerate
Useful after changing image size settings, or switching themes
13
Create Posts
Create 100 posts:
wp post generate --count=100
14
Create Pages
Create 100 pages, 3 levels deep:
wp post generate --count=100 --post_type=page --max_depth=3
15
Create New Plugin
Create a new (empty) plugin and activate it:
wp scaffold plugin myplugin --plugin_name='My Plugin' --activate
Useful when developing a new plugin
16
Download & Install WordPress
cd /path/to/empty/directory/
wp core download
wp core config --dbname=wpcli --dbuser=wpcli --dbpass=wpcli
wp core install
17
Also:
Add/manage comments
Add/manage users
Database import/export
Change WordPress options
Heaps more!
18
Questions?
http://wp-cli.org/
https://github.com/wp-cli/wp-cli
These slides are online at: http://jamesc.id.au/wp-cli/
19