+ All Categories
Home > Technology > Command Line WordPress with WP-CLI

Command Line WordPress with WP-CLI

Date post: 28-Jan-2015
Category:
Upload: james-collins
View: 124 times
Download: 0 times
Share this document with a friend
Description:
How to use WP-CLI to manage your WordPress Installations. Using WP-CLI you can: Install WordPress, update WordPress, install plugins, update plugins, database search and replace, create test posts and pages, create new plugins, manage comments, manage users, perform database imports/exports, and more. A presentation given that the WordPress Melbourne User Group September 2013 Meetup (http://www.meetup.com/WordPress-Melbourne/events/112574042/).
Popular Tags:
19
Command Line WordPress with WP-CLI James Collins @om4james http://jamesc.id.au / WordPress Melbourne User Group - September 2013
Transcript
Page 1: Command Line WordPress with WP-CLI

Command Line WordPress with WP-CLI

James Collins

@om4jameshttp://jamesc.id.au/

WordPress Melbourne User Group - September 2013

Page 2: Command Line WordPress with WP-CLI

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

Page 3: Command Line WordPress with WP-CLI

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

Page 4: Command Line WordPress with WP-CLI

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

Page 5: Command Line WordPress with WP-CLI

What Can It Do?

5

Page 6: Command Line WordPress with WP-CLI

WordPress Core

Update WordPress core:

wp core update

Upgrade WordPress database:

wp core update-db

6

Page 7: Command Line WordPress with WP-CLI

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

Page 8: Command Line WordPress with WP-CLI

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

Page 9: Command Line WordPress with WP-CLI

WordPress Themes

Update all themes:

wp theme update-all

List all themes:

wp theme status

I = Inactive, A = Active, U = Update Available

9

Page 10: Command Line WordPress with WP-CLI

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

Page 11: Command Line WordPress with WP-CLI

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

Page 12: Command Line WordPress with WP-CLI

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

Page 13: Command Line WordPress with WP-CLI

WordPress Media/Uploads

Regenerate/recreate WordPress thumbnails:

wp media regenerate

Useful after changing image size settings, or switching themes

13

Page 14: Command Line WordPress with WP-CLI

Create Posts

Create 100 posts:

wp post generate --count=100

14

Page 15: Command Line WordPress with WP-CLI

Create Pages

Create 100 pages, 3 levels deep:

wp post generate --count=100 --post_type=page --max_depth=3

15

Page 16: Command Line WordPress with WP-CLI

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

Page 17: Command Line WordPress with WP-CLI

Download & Install WordPress

cd /path/to/empty/directory/

wp core download

wp core config --dbname=wpcli --dbuser=wpcli --dbpass=wpcli

wp core install

17

Page 18: Command Line WordPress with WP-CLI

Also:

Add/manage comments

Add/manage users

Database import/export

Change WordPress options

Heaps more!

18

Page 19: Command Line WordPress with WP-CLI

Questions?

http://wp-cli.org/

https://github.com/wp-cli/wp-cli

These slides are online at: http://jamesc.id.au/wp-cli/

19


Recommended