Home » Functions » delete_theme

The delete_theme() function in WordPress is used to delete a theme from the file system of your website. It can be used to remove an unwanted or unused theme, or to replace an outdated theme with a new one.

When you delete a theme using this function, all the files associated with the theme will be removed from your website’s file system. This includes any templates, images, scripts, or other files that were used by the theme.

To use the delete_theme() function, you need to know the name of the theme that you want to delete. You can find the name of the theme by checking the name of the theme directory in the wp-content/themes/ folder.

Here is an example usage code:

$theme = 'my-theme'; // Replace "my-theme" with the name of the theme you want to delete.

// Delete the theme.

This code will delete the theme named "my-theme" from your WordPress website. If the theme is currently active, it will be deactivated before it is deleted.

Learn More on

Register an account to save your snippets or go Pro to get more features.