Tjeneste-oppgradering: Følg linken for nærmere status vedrørende migrering, for generelle spørsmål og svar se vårt hjelpesenter.

WP-CLI tips and commands


EXPERIENCING PROBLEMS WITH OUR SERVICES? RUN A DIAGNOSE FIRST TO SAVE YOURS AND OUR TIME

Added: 14.11.2019 11:31:37     Last updated: 19.10.2020 12:51:27

What is WP-CLI?

WP-CLI is the command line interface for WordPress. You can update plugins, configure multisite installations and much more, without using a browser. For example, it can be used in "Terminal" inside cPanel.
It is installed on all our servers and can be used as long as one has Pro Medium or larger web hosting.

Useful commands with examples

There are many commands available for WP-CLI, but on this page we will only go over a few examples. For more detailed commands, we recommend taking a look at the manual.

1. Help
The command below will list subcommands and parameters that can be used with the "wp" command.

wp help


2. Information
wp cli info will display some information that may be useful to use for different occasions.
It will list the things below:

  • OS information.
  • Shell information.
  • PHP path.
  • PHP version.
  • php.ini configuration file in use.
  • WP-CLI root / vendor dir: where WP-CLI is installed.
  • WP-CLI version: installed version.
wp cli info


3. Database backup
Backup is often necessary to make prior to major changes or upgrades to the website. The command will export the WordPress database as a .sql file in the same directory as the WordPress install.
It is also possible to export to the desired filename instead of a random name by using the command: wp db export choosename.sql

wp db export


4. Database repair and optimization
To avoid logging into phpMyadmin and cPanel you can optimize and repair the database directly from wp-cli with the commands below.

wp db repair
wp db optimize


5. Size of database and tables
If you want to check the sizes of the tables and if any of them need optimization then the command below will list all the sizes of all tables in the database.

wp db size --tables --human-readable

6. wp-config information and path
Sometimes wp-config.php may be located in a folder other than the WordPress installation itself. Then the following command may be useful to find the entire path of the file:

wp config path

If you need to see for example the database password and the rest of the wp-config.php file without opening and downloading the file, this can be done with the command:

wp config get


7. Plugin overview
The commands below will list all plugins, both active and inactive. It will also show which plugins have available updates.

wp plugin list
wp plugin status

8. Plugin update
If the akismet plugin is outdated it can easily be updated with the wp-cli command:

wp plugin update akismet

If you want to update all plugins on the page, this command can be used:

wp plugin update --all

9. How to update WordPress themes with WP CLI

wp theme update --all

For a full overview, check out the developer reference at WordPress.