1 of 23

1

Speaker

Aditya Shah

WordCamp Nepal 2022

5-6 November. 2022

Bharatpur, Nepal

2 of 23

HI!

2

3 of 23

  • Hosting Support Lead at WPMUDEV

  • Organizer, WordPress Bhopal Community

  • 10+ years in WordPress��

3

4 of 23

WP- CLI

4

5 of 23

INTRODUCTION

  • What is WP-CLI?

  • Why WP-CLI?

  • Who this is for?

  • What would you need?

5

6 of 23

Let’s start!

6

7 of 23

What is WP-CLI?

  • A set of command line tools that allows you to manage WordPress from the command line.

  • https://www.wp-cli.org/

7

8 of 23

Why WP-CLI?

  • Migration

  • Performing any action takes fewer steps

  • Gives better control

  • Background jobs

8

9 of 23

Who this is for?

Anyone really, but mostly:

  • Developers

  • Support Engineers

  • Server Administrators

  • Site Administrators

9

10 of 23

Let’s get started?

What would you need-

Install : https://wp-cli.org/

Requires PHP 5.3.2 or later

Requires Wordpress 3.5.2. or later

A “UNIX-like” environment:

OSX (Macintosh)

Linux

Cygwin (Windows)

10

11 of 23

Installing WP-CLI

  • To install WP-CLI on your server, run these commands-

$ curl -0 https://raw.githubusercont

$ chmod +x wp-cli.phar

$ mv wp-cli.phar /usr/local/bin/wp

  • To check if the installation was successful, run-

$ wp - -info

11

12 of 23

12

13 of 23

Running Commands

wp <command> <sub-command> <params>

13

14 of 23

Running Commands

<param> – required

[--param] – optional flag

[--param=<value>] — optional w/ value

14

15 of 23

Core

Downloads, installs, updates & manages a WordPress installation.

$ wp core download

15

16 of 23

db

Performs basic database operations using credentials stored in wp-config.php.

wp db export backup.sql

wp db import backup.sql

wp db cli

16

17 of 23

Search-replace

Searches/replaces strings in the database, including serialised arrays.

$ wp search-replace

‘foo’ ‘bar’

17

18 of 23

Post

  • Generate Test Content!

wp post generate –count=500

  • Create post with random content using Any Ipsum Plugin

wp plugin install any-ipsum —activate

wp any-ipsum generate posts 100

18

19 of 23

Media

Regenerate thumbnails

wp media regenerate —yes

19

20 of 23

Create users

wp user create

wp user generate

wp user import-csv

20

21 of 23

21

22 of 23

Let’s Connect

@ethicaladitya

@wpmudev

22

23 of 23

THANK YOU!

23