Change WordPress Theme Using WP-CLI

InMotion Hosting’s WordPress Hosting features WordPress Command Line Interface (WP-CLI). WP-CLI allows you to use the command line to efficiently maintain your WordPress website(s). In our previous guide, Install a Theme Using WP-CLI we introduced the wp theme command. In this guide, you will learn how to list your installed themes and how to change the theme for your WordPress website using WP-CLI.

List Installed Themes

  1. SSH into your server as the cPanel user that owns the website you would like to list the themes for.

  2. Use the cd command to switch to the document root directory of your website.

    Example: cd public_html/my_website

  3. Run the following subcommand, to list your currently installed themes:

    wp theme list

  4. The example output below, indicates that we have four (4) themes installed.

    exampl3@example.com [~/public_html]# wp theme list +-----------------+----------+--------+---------+ | name            | status   | update | version | +-----------------+----------+--------+---------+ | boldgrid-primas | inactive | none   | 1.23.1  | | boldgrid-swifty | active   | none   | 1.1.1   | | twentyfifteen   | inactive | none   | 1.9     | | twentyseventeen | inactive | none   | 1.4     | | twentysixteen   | inactive | none   | 1.4     | +-----------------+----------+--------+---------+

    Under the status column, active appears next to the theme that is currently activated for the website.

Now that you are familiar with listing the installed themes, you can follow the instructions in the next section to change the active theme for your website to one of the themes listed. If you have not yet installed the theme you would like to change to, you can follow our guide Install a Theme Using WP-CLI.

Change Theme

Once you have a theme in mind to change your website to, you can simply use the wp theme command to activate it.

  1. SSH into your server as the cPanel user that owns the website you would like to change the theme on.

  2. Use the cd command to switch to the document root directory of your website.

    Example: cd public_html/my_website

  3. Run the following subcommand, to list your currently installed themes:

    wp theme activate boldgrid-primas
  4. Once the theme is activated, you will receive a successful message, like the one below:

    exampl3@example.com [~/public_html]# wp theme activate boldgrid-primas Success: Switched to 'Primas' theme.

Congratulations! You now know how to list the installed themes and how to change the theme for your WordPress site, using WP-CLI.

Leave a Reply