How to Maximize the WordPress Command Line Interface – TechCo (blog)

The WordPress format may be easy to work with, but it still requires a lot of time to keep everything updated. Fortunately, developers who are looking to shave a few minutes off of their work can turn to the WordPress Command Line Interface (WP-CLI). Instead of configuring installs for multiple sites or updating plugins from a browser, you’ll be able to handle everything from the WP-CLI.

Installing this helpful feature is step one, but you also need to learn how to put it to work for you. The good news is that most of the commands are very intuitive, so anyone who has basic coding knowledge should have no problem figuring it out.

To help you get started, here’s a tutorial on some of the most commonly used WP-CLI features:

Installing a Plugin

You can quickly install new plugins within the WP-CLI. There are many variations you can utilize based on your exact needs, but “$ wp plugin install” is the basic code to enter, minus the quotation marks. From there, you’ll need to add the plugin’s name, along with instructions about other options such as whether or not to activate the plugin immediately. The final line of code will often look like this:

$ wp plugin install pluginname –activate

Here’s How To Become A Professional Coder On Your Own Time

Managing Themes

WordPress themes can be managed from the WP-CLI. You’ll have the ability to do everything necessary to identify, download and install a theme:

Deleting a Transient Value

This is where the WP-CLI really showcases its value. Currently, users are unable to delete one or all transient values from within the WordPress dashboard. WP-CLI has solved this problem, which enables you to use two lines of code to clean up your WordPress site. To isolate and remove one transient value, use the following code and replace “sample_key” with the transient in question:

Delete transient.
$ wp transient delete sample_key

You can add additional text to both lines of code to take even more control over the deletion process. For example:
#Delete expired transients.
$ wp transient delete –-expired

There’s also an option to delete all transients at once:
#Delete all transients.
$ wp transient delete –-all

Is the WordPress Command Line for Everyone?

As you can see from the three features highlighted above, the WP-CLI is a suitable option for website developers who enjoy working with code. However, the tool does have four requirements that users must meet:

  1. WP-CLI needs UNIX to run.
  2. Your PHP must be version 5.3.29 or later.
  3. You must be working with WordPress 3.7 or later.
  4. Your hosting environment must have Secure Shell (SSH) access.

Website developers and coders who meet this list of requirements can dramatically alter their WordPress experience. The WP-CLI isn’t going to enable you to create a website from scratch, but it certainly offers many useful features for updating a site and adding new features.

Read more about programming at TechCo

こんな記事も読まれています

コメントを残す