Switching your Theme via WP-CLI | BoldGrid

Switching your Theme via WP-CLI

If you need to change your Theme when you are not able to access the WordPress Dashboard, one of the fastest methods is to use the WordPress Command Line Interface or WP-CLI.

  1. SSH into your WordPress hosting environment, following your Web Host’s instructions for doing so.
  2. Change directories to the root directory containing your WordPress installation. In these examples, the directory ~/public_html is used in place of the root directory for WordPress.
    user@wordpress [~]$ cd ~/public_html/
  3. Get a list of your available themes with the command wp theme list:
    user@wordpress [~/public_html]$ wp theme list
    +------------------+----------+--------+---------+
    | name             | status   | update | version |
    +------------------+----------+--------+---------+
    | boldgrid-hifidel | inactive | none   | 1.24.3  |
    | crio             | active   | none   | 2.1.3   |
    | twentynineteen   | inactive | none   | 1.4     |
    | twentyseventeen  | inactive | none   | 2.2     |
    | twentysixteen    | inactive | none   | 2.0     |
    +------------------+----------+--------+---------+
    

    In this example, the Theme Crio is currently active, and the list of names, or slugs, shows the other themes you have available.

  4. Switch to another theme with the command wp theme activate theme-slug, where you replace “theme-slug” with the name of the theme you are activating:
    user@wordpress [~/public_html]$ wp theme activate twentynineteen
    Success: Switched to 'Twenty Nineteen' theme.

    In this example, the Theme TwentyNineteen has been activated.

  5. If you receive an error, you may need to add one of the following modifiers to your command: –skip-themes or –skip-plugins
    user@wordpress [~/public_html]$ wp theme activate twentynineteen --skip-themes --skip-plugins
    Success: Switched to 'Twenty Nineteen' theme.

Congratulations! You now know how to switch themes with WP-CLI.

 

Get more for free by signing up with BoldGrid Central Create Account