Change my WordPress theme with WP-CLI
WP-CLI is a command line tool that helps you perform different actions on your WordPress site. If you're comfortable with using SSH commands, you'll notice that WP-CLI has simplified commands created for WordPress sites. If you're changing the theme for troubleshooting purposes, we recommend switching to one of the default WordPress themes.
Warning: You should always back up your site before changing your theme.
Required: You'll need the following to complete these steps:
- An SSH app. We suggest PuTTY for Windows, or Terminal for macOS.
- Your FTP details. If you don’t have them already written down, you should find your FTP host, username, and password:
- For your FTP host, you can use either your domain name or your IP address.
- You can find your FTP username and password in your hosting account for Linux Hosting with cPanel or Managed WordPress Hosting (steps 1-7).
Note: If you have a VPS or DED Server, you need to install WP-CLI before you can start using it. WP-CLI is not available on our Windows Hosting plans.
- Connect to your hosting account with SSH.
- Use the bash command ls to list files and folders, and cd and ../ to move through directories until you're in the directory with your WordPress files.
- Enter the following command to see the list of themes installed on your site.
wp theme list
- (Optional) If there are themes you don’t intend to use, you can delete them with the following command:
wp theme delete theme-name
In the code above, replace theme-name with the actual name of the theme you want to delete.
- (Optional) If there are themes you don’t intend to use, you can delete them with the following command:
- If you want to use the theme that is not installed on your site, here's how to install it. Otherwise, skip this step.
- To install a theme from the WordPress repository, enter the following command:
wp theme install theme-name
In the code above, replace theme-name with the actual name of the theme you want to install. - To install a theme from a .zip file, upload the theme .zip file to the folder with your WordPress installation using FTP or File Manager. Then, enter the following command:
wp theme install theme-name.zip
In the code above, replace theme-name.zip with the actual name of the .zip file you've previously uploaded.
- To install a theme from the WordPress repository, enter the following command:
- Activate the theme with the following command:
wp theme activate theme-name
In the code above, replace theme-name with the actual name of the theme you want to activate. - After you see the success message, visit your site in a browser to see if it works as intended. For any theme-specific issues, check your theme developer’s documentation.
Note: To install and activate a theme at the same time, append the install command with --activate. Here is how that command would look:
wp theme install theme-name --activate
More info
- Export and import a database with WP-CLI
- Troubleshooting WordPress
- Want to know more about WP-CLI? Find developer specific info on their official site.