WPCLI VI

WP-CLI How-To: Using WP-CLI to Manage your WordPress Installation

WP-CLI (WordPress Command Line Interface) is a set of command line tools for easily managing WordPress installations.

This how-to briefly introduces some possibilities WP-CLI has to offer. (Show all commands on wp-cli.org)

Content

How-To

Requirements and preparation

Important: WP_CLI requires a package with SSH access.

Log in to your installation via SSH and go to the WordPress root folder. Enter all commands directly in the command line and confirm with Enter.

Displaying WP-CLI commands

To list all commands:

wp help

Tip: To get more help on a certain command, use:

wp help command

Example: To get help on the search and replace command:

wp help search-replace

Checking and updating your WordPress version with WP-CLI

You can check and update the WordPress core files of your installation.

Display current version:

wp core version

Update WordPress core to latest version:

wp core update

Managing plugins and themes with WP-CLI

You can display the status of your WordPress plugins and themes and update them.

Display status of all plugins:

wp plugin status

Update a plugin

wp plugin update plugin-name (Example: wp plugin update akismet)

Update all plugins:

wp plugin update --all

Install plugin:

wp plugin install plugin-name

Activate plugin:

wp plugin activate plugin-name

Follow the same pattern for themes. For example, wp plugin status becomes wp theme status.

Search and replace

With search and replace you can easily replace the domain of your WordPress installation for example:

wp search-replace http://old-domain.com http://new-domain.com

Working with posts

Creating a page entitled My post and publishing it:

wp post create --post_type=page --post_status=publish --post_title='My post' --post_content='My text: Lorem Ipsum...'

Most calls will return information. For example: wp post create will return the post ID. You can use that to manipulate or delete specific content:

wp post meta add <id> <key> <value> or wp post delete <id>

Deleting a post:

wp post delete <id> --force

 

Please rate this post :

Leave a Reply

Your email address will not be published. Required fields are marked *