WP-CLI makes it quick and easy to manage your WordPress themes.
To use WP-CLI, first, SSH in to your server as your WordPress app's system user; do not use root with WP-CLI as it could break your app.
Then, navigate to your app's public directory by entering the following commands, replacing "APPNAME" with your app's name:
cd apps cd APPNAME cd public
Now, type wp theme and press Enter. You'll be given a list of the acceptable arguments for this command:
usage: wp theme activate <theme> or: wp theme delete <theme>... or: wp theme disable <theme> [--network] or: wp theme enable <theme> [--network] [--activate] or: wp theme get <theme> [--field=<field>] [--fields=<fields>] [--format=<format>] or: wp theme install <theme|zip|url>... [--version=<version>] [--force] [--activate] or: wp theme is-installed <theme> or: wp theme list [--<field>=<value>] [--field=<field>] [--fields=<fields>] [--format=<format>] or: wp theme mod <command> or: wp theme path [<theme>] [--dir] or: wp theme search <search> [--per-page=<per-page>] [--field=<field>] [--fields=<fields>] [--format=<format>] or: wp theme status [<theme>] or: wp theme update [<theme>...] [--all] [--format=<format>] [--version=<version>] [--dry-run] See 'wp help theme <command>' for more information on a specific command.
This tutorial will cover the most common uses for wp theme.
Enter this command to show a summary of your installed themes' various states:
wp theme list
The output will look similar to the following:
+-----------------+----------+--------+---------+ | name | status | update | version | +-----------------+----------+--------+---------+ | twentyfifteen | inactive | none | 1.7 | | twentyseventeen | active | none | 1.1 | | twentysixteen | inactive | none | 1.3 | +-----------------+----------+--------+---------+
This displays the active theme, any available updates for your themes, and the present version of the theme installed on your app.
Enter this command to install a new theme, replacing "THEMENAME" with the name of the theme you would like to install:
wp theme install THEMENAME
This will give an output similar to the following as your theme is installed:
wp theme install twentyfifteen Installing Twenty Fifteen (1.7) Downloading install package from https://downloads.wordpress.org/theme/twentyfifteen.1.7.zip... Unpacking the package... Installing the theme... Theme installed successfully. Success: Installed 1 of 1 themes.
If the system is unable to locate a theme with the provided name, it will fail like so:
wp theme wrongtheme Error: 'wrongtheme' is not a registered subcommand of 'theme'. See 'wp help theme'.
You can also activate a theme when you install it by using this command:
wp theme install THEMENAME --activate
Enter this command to easily update one theme:
wp theme update THEMENAME
The system will display a success or failure message.
You can update all of your themes by entering this command:
wp theme update --all
The system will display a success or failure message.
Enter this command to activate a theme:
wp theme activate THEMENAME
You will receive a message similar to this when the task is complete:
wp theme activate twentysixteen Success: Switched to 'Twenty Sixteen' theme.
First, make sure the theme is not active by listing all themes:
wp theme list
Then, delete the chosen theme by typing the following, using the exact name of the theme in the list:
wp theme delete THEMENAME
Your results will look similar to the following:
wp theme delete twentyfifteen Deleted 'twentyfifteen' theme. Success: Deleted 1 of 1 themes.
You can find more information in the official WP-CLI documentation.