Update and Delete Wordpress Themes
Three Ways to Update and Delete Wordpress Themes
Wordpress is the favorite CMS of a vast number of bloggers and webmasters. It is known to power more than 43% of all the websites. The CMS offers a vast number of themes and plugins that can be utilized to improve site functionality. Themes play a central role in terms of website appearance, ussr experience, speed and SEO.
In a previous post, we have discussed the methods to install and activate a wordpress theme. You can install themes from the wordpress repository which includes only the free themes. Premium themes need to be downloaded as zip files and can be then uploaded to the wordpress dashboard before activation.
Another easy method to install and activate themes is to use the WP-CLI, which can be used to install and activate themes from the Wordpress repository.
However, you will also need to update the themes whenever a new version is released to ensure compatibility and improved functionality. Apart from new functionalities and features, updates sometimes also include bug fixes and are essential for the smooth operation of your blog.
Update Wordpress theme from Wp dashboard
The most commonly used method for installing and updating themes is via the wordpress dashboard. If you have a free theme that you have installed from the wordpress theme repository, you can easily update it from the dashboard. If there is an update available, you will see a notification on the wordpress dashboard.
To check out which theme needs to be updated, you can go to the updates section or visit themes directly. Go to Appearance -> Themes and check out the installed themes. The theme that requires an update will show a notification saying “New version available - Update now.”
If you click on the theme, it will expand to cover the screen. Now, if you want to check out the details regarding the updated version and the changes it includes, you can do it from here. Click on view version details to check out the changes.
To update the concerned theme, click on update now. If you want a theme to auto-update whenever there is an update available, you can also do it from here. Click on enable auto updates and the theme will update automatically in the future whenever a new version is available.
Before you update a theme, it is good to switch to another if it is your currently active theme. Always keep an extra theme for fall back in case anything goes wrong with the current theme. Switch to another theme before updating and once you have successfully updated the theme switch back to it to check if everything is fine at the front end.
Upload updated theme using FTP or through dashboard
While free themes can be easily updated from the wordpress dashboard, premium themes may sometimes require you to download a new version and upload it. Most premium themes however, allow you to update directly. Yet, you can download the latest version from the theme provider and then upload it to your theme folder.
Suppose, you want to update a theme with the latest version. You can download the latest version as a zip file from the provider’s website. Now, go to the Wordpress dashboard and Appearance -> Themes. Now, click on add new and then upload. Click on choose files to select the theme zip file and upload it. If you have a previous version of the theme already installed on your wordpress blog, the latest version will replace it.
You can also update themes using SFTP. This method also proves useful when you need to upload or delete a theme but cannot access the Wordpress dashboard. You will need an FTP Client like Filezilla or Cyberduck to connect with your server for uploading files.
Open cyberduck and click on open new connection. Now, enter the credentials including host, user name, password and port number. Click on connect and then Allow. Once connection is established, go to the root folder, or the folder in which you have installed Wordpress.
From the root folder, go to wp-content and then open the themes folder. Suppose, your root folder’s location is /var/www/html, you will need to go to /var/www/html/wp-content/themes. You can delete the previous version of the theme and upload the new version. To delete a file using Cyberduck, right click on the file or folder and from the menu select delete. Once you have uploaded the updated version, go back to your Wordpress dashboard and you will find the updated version among the installed themes. You can now activate it to check out if anything needs customization.
It is very important to keep your themes and plugins updated. Timely theme and plugin updates are essential not just for compatibility, but also for Wordpress security.
Update a Wordpress theme using WP-CLI
The WP-CLI or Wordpress Command Line Interface provides an easy method to maintain your wordpress plugins and themes. You can use the CLI to install and activate themes as well as to update them.
When using the CLI, you will not need to login to the Wordpress dashboard but with just a few simple commands, you can update themes and plugins.
However, to run WP-CLI commands, you will first need to have the WP-CLi installed on your server. After installing the CLI, you can manage multiple Wordpress tasks directly from the command line.
Installing WP-CLI is easy and requires downloading the wp-cli.phar using wget or curl:
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
Now, make the file executable and move it to somewhere in your PATH:
chmod +x wp-cli.phar
sudo mv wp-cli.phar /usr/local/bin/wp
To verify that the CLI was successfully installed, run the following command:
wp --info
An output like the following shows that the CLI was successfully installed:
OS: Linux 5.15.0-67-generic #74-Ubuntu SMP Wed Feb 22 14:14:39 UTC 2023 x86_64
Shell: /bin/bash
PHP binary: /usr/bin/php8.2
PHP version: 8.2.8
php.ini used: /etc/php/8.2/cli/php.ini
MySQL binary: /usr/bin/mysql
MySQL version: mysql Ver 8.0.32 for Linux on x86_64 (MySQL Community Server - GPL)
SQL modes: ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION
WP-CLI root dir: phar://wp-cli.phar/vendor/wp-cli/wp-cli
WP-CLI vendor dir: phar://wp-cli.phar/vendor
WP_CLI phar path: /var/www/html
WP-CLI packages dir:
WP-CLI cache dir: /root/.wp-cli/cache
WP-CLI global config:
WP-CLI project config:
WP-CLI version: 2.8.1
Now, we will first check if any of our installed themes has an update available. To do that, run the following command:
wp theme list
It will output a list like the following:
+-------------------+----------+-----------+---------+
| name | status | update | version |
+-------------------+----------+-----------+---------+
| astra | inactive | none | 4.3.0 |
| blocksy | inactive | available | 1.9.2 |
| generatepress | active | none | 3.3.1 |
| twentynineteen | inactive | none | 2.5 |
| twentytwentythree | inactive | none | 1.2 |
+-------------------+----------+-----------+---------+
You can see that the above output includes the status of available updates for each theme. Now, you know the theme that requires an update. All that remains to be done is to use the wp theme update command like below:
wp theme update blocksy
Here we run the wp theme update command and append the name of the theme requiring update. Its output will look like the following:
wp theme update blocksy
Downloading update from https://downloads.wordpress.org/theme/blocksy.1.9.3.zip...
Unpacking the update...
Installing the latest version...
Removing the old version of the theme...
Theme updated successfully.
+---------+-------------+-------------+---------+
| name | old_version | new_version | status |
+---------+-------------+-------------+---------+
| blocksy | 1.9.2 | 1.9.3 | Updated |
+---------+-------------+-------------+---------+
Success: Updated 1 of 1 themes.
So, this is how you can easily update a wordpress theme using the WP-CLI.
How to delete a Wordpress theme
Just like updating a wordpress theme, there are also three methods to delete a theme. The first method is to delete a theme from the dashboard. The second method involves the use of FTP and the third method is slightly technical and for those skilled with running the terminal commands. In the third method you can delete a wordpress theme using the WP-CLI.
Delete wordpress theme from wp-dashboard
To delete a theme from the Wordpress dashboard, go to Appearance ->Themes and then hover the cursor over the theme that you want to delete. Click on theme details. It will expand the theme and you will now see the delete button at the bottom on the right side. Click on delete to delete the theme. That’s all. You have successfully deleted the theme from your blog.
Delete wordpress theme using FTP Client
Wordpress themes can also be deleted using an FTP Client. This option also comes in handy if you have somehow lost access to your wordpress dashboard or if your Wordpress dashboard is unreachable due to some error. In such a situation, if you want to change the theme, you can delete the active theme from FTP using an FTP CLient like Filezilla or Cyberduck.
Open a new connection in cyberduck and then go to the root folder and then wp-content and open the themes folder. Now you can select the theme folder that you want to delete and delete it.
Just right click on the theme folder that you want to delete and then click on delete from the menu.
Delete Wordpress theme using the WP-CLI
The WP-CLI is a great tool for managing themes and just like you install or update themes using the CLI, you can delete a theme easily using the CLI.
In some situations, when there is a problem with yo0ur currently active theme and you are unable to delete it from the dashboard, the CLI can help you delete the active theme as well.
To delete a theme using the WP-CLi, you need to run the wp theme delete command, followed by the name of the theme or themes that you want deleted.
For example:
wp theme delete astra
The output of the above command will look like the following:
Deleted 'astra' theme.
Success: Deleted 1 of 1 themes.
If the theme you want to delete is the active theme, you can use the –force flag. However, before deleting an active theme, please make sure that you have at least one more theme installed so that wordpress can switch to it.
wp theme delete astra --force
So, this is how you can easily delete a theme or more than one theme using the WP-CLI. When you need to delete more than one theme, append their names separated by a space.
Please note that you will need to switch to the root directory when you are using the WP-CLI. Otherwise, you will need to append the path to the root folder to each command like –path=/var/www/html. If you are outside the root folder and trying to run the WP-CLI commands without providing the path, the system will throw an error.
You should not try to run the wp-cli commands as the root user either since in that case too, the system will throw an error. To overcome it, you can switch to another sudo user or use the –allow-root flag after the ali command.