August 18, 2017
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
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:
- To get a list of your current themes: [[email protected]]$ wp theme list
- To search for a new theme: [[email protected]]$ wp theme search
- To install your new theme: [[email protected]]$ wp theme install
- To activate your new theme: [[email protected]]$ wp theme activate
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:
- WP-CLI needs UNIX to run.
- Your PHP must be version 5.3.29 or later.
- You must be working with WordPress 3.7 or later.
- 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
Did you like this article?
Get more delivered to your inbox just like it!