What is WP-CLI and what can it do for you?

Connect on Social

So what is WP-CLI?

WP-CLI or the WordPress Command Line Interface is a PHP based tool that allows you to manage your WordPress site via SSH (Secure Shell) interface.

In simpler terms, it is the back-door to your website. WP-Admin is the GUI or Graphical User interface gives you something nice to look at, with buttons and colours that can be accessed via a web page. WP-CLI drops the GUI and works with simple commands, providing more control and speed.

Why should you use WP-CLI?

This will depend on whether you manage one site or multiple sites but there is always benefit to using WP-CLI. When I am doing regular maintenance on a site or inspecting a client site for the first time there are several commands I always run.

Fundamentals of a WP-CLI command

wp <command> <subcommand> –<option-with-value>=<option-value> –<option-without-value>

WP-CLI install page has details on how to add tab completions so you just hit tab and get a list of available commands, sub-commands and options. https://wp-cli.org 

Let’s dig deeper and see what we can do!

Managing Users.

Database management

Also a number of maintenance tools for DB as well but be very careful running them. Best rule if you are not sure, don’t run them.

Posts

Building and Scaffolding Sites

Here are some more detailed commands for building and setting up your sites. You will need a database in place before you begin.

Advanced commands and Piping

Here a some more advanced commands that you can use for testing and fault finding. I would highly advise you don’t use these on a production server as they will change your site and possibly prevent it from being accessed via a web page.

These commands are for development & staging environments only and make sure you do a wp db export database-name.sql first as insurance.

That is only a small sample of commands for WP-CLI. Here are some links for beginners and advanced users as well as a few posts on how to install WP-CLI on your host.

 

Home of WP_CLI – https://wp-cli.org/

Beginners Guide to WP-CLI
https://code.tutsplus.com/tutorials/what-is-wp-cli-a-beginners-guide–cms-28649

WP-CLI Tips by John Blackbourn (Creator of Query-Monitor)
https://tinyletter.com/wp-cli-tips
https://tinyletter.com/wp-cli-tips/archive

WP-CLI – Advanced WordPress Management
https://www.smashingmagazine.com/2015/09/wordpress-management-with-wp-cli/

Other External Resources
https://make.wordpress.org/cli/handbook/external-resources/

Installing on Shared Host
https://swapnil.blog/2018/01/10/installing-wp-cli-on-shared-hosting/
https://au.godaddy.com/help/how-to-install-wordpress-cli-on-shared-hosting-12363

The short URL of the present article is: https://wp.me/p7fZqS-6S

About Mr Wilde

Technology has been in my blood for as long as I can remember. Started with Dick Smith kits when I was 10, I was making FM wireless bugs in high school. After several years working, Electronics Technician, Sound and Lighting Technical Director and then IT Sysadmin, I am going with the flow and leaving the hardware behind, mostly. I am now developing solutions for the cloud, focus on WordPress, SharePoint and Mobile devices. Learning more and more every day.


Leave a Reply

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

%d bloggers like this: