How to use WP-Optimize from the command line
We’ve added WP-CLI support to our WP-Optimize Premium plugin.
WP-CLI is the command-line interface for WordPress that allows you to do all kinds of things, such as updating plugins and configuring multisite installs, without using a web browser.
Including it in WP-Optimize Premium means that you will now be able to run optimization commands directly on command-line. During this operation, WP-Oprtimize will perform in exactly the same way, but it will produce a detailed output on screen to show you what’s happening.
This feature is mainly for the experienced user, but it’s easy enough for anyone to set up and run.
Here’s how it works
- Before running an optimization, you will need to gather a list of optimizations available to you on command-line. To do this, you will need to run the following:
wp optimize optimizations
This will bring out the list of optimizations, as below:
| Command | Function |
|---|---|
optimizetables | Optimise database tables |
revisions | Clean all post revisions |
trash | Clean all trashed posts |
spam | Remove spam and binned comments |
unapproved | Remove unapproved comments |
attachments | Remove orphaned attachments |
transient | Remove expired transient options |
pingbacks | Remove pingbacks |
trackbacks | Remove trackbacks |
postmeta | Clean post meta data |
commentmeta | Clean comment meta data |
orphandata | Clean orphaned relationship data |
| Command | Function |
|---|---|
version | To return the current WP-Optimize version |
optimization | Displays a full list of commands (as seen up above) to optimize |
do-optimization --optimization-id= | Running the selected optimization |
--path= | Add this just after wp to specify the WordPress install e.g. wp --path=/var/www/html/work/multisite optimize do-optimization --optimization-id=orphandata |