Tutorial · wordpress · Published 2026-08-16 · 4 min read
Activate and manage themes with WP-CLI
Manage WordPress themes with WP-CLI: list, install, activate, switch, deactivate and update themes safely from the command line.
Why manage themes from the CLI
The WordPress admin (Appearance > Themes) is a graphical toggle that also loads the whole dashboard, runs hooks on every view, and reloads the page when you switch. WP-CLI does the same work in one command that is fast, scriptable and auditable. That matters when you are switching a theme as part of a deployment, reverting a bad theme change under pressure, or automating staging-to-live where no browser opens.
WP-CLI and the wp theme command set operate on the filesystem and the active-theme option in the database, so they share the same state the admin shows. The WP-CLI versus panel comparison frames when the CLI is the right tool.
The theme commands
wp theme list # name, status (active/inactive), version, update
wp theme activate twentytwentyfive # switch the active theme
wp theme deactivate mytheme # fall back to the default
wp theme install twentytwentyfive # fetch from the theme directory
wp theme update twentytwentyfive # update an installed theme
wp theme delete mytheme # remove it (already deactivated)
wp theme listshows a wide table by default;--fields=name,status,versionnarrows it.- Activation switches the theme immediately:
wp theme activate twentytwentyfivemakes that theme the one visitors and the admin see. wp theme installaccepts a slug (from the theme directory) or a URL to a zipped theme;--activateinstalls and activates in one step.- Deactivate is rarely needed on a single install; it exists to roll back to the previous theme without clicking.
The safe activation order
- Take a pre-change snapshot of the relevant state:
wp option get templateandwp option get stylesheet(orwp theme list) tell you both what is active and what the previous value was. - Install in staging first if the theme is new;
wp theme installon staging avoids polluting production with a half-tested theme. - Activate on the live site with
wp theme activate <slug>. - Verify instantly:
wp theme listagain and, where possible, curl the homepage for a 200 rather than a 500 or a blank document. A common activation failure is a theme that assumes the wrong base URL or loads a plugin that errors; the troubleshooting order walks that. - Keep the fallback ready: the default theme (twenty-*) is usually still installed, so
wp theme activate twentytwentyfouris the revert.
What the CLI does with child themes
For the parent or child switch, the pieces act on the template (parent) and stylesheet (child) options. Installing a child theme keeps the parent active; wp theme activate my-child sets template to its parent and stylesheet to the child. If you operate on a child theme and the parent is missing, the admin breaks; the CLI falls back to pretending the child is the parent. Keeping both themes installed is the safe position.
Safety and rollback
- Run
wp theme status(deprecated alias ofwp theme list) before any change to know the current set. - The revert path for a broken activation is
wp theme activate <the old slug>from the CLI, which works even when the admin is white-screening because a theme fatal'd. - Never delete a theme that is the active one; WP-CLI refuses to delete the active theme and requires it to be deactivated first, so the command is safe even from a script.
Prevention
Keep the active-theme pair (template + stylesheet) in your deployment notes, switch only through staged where production matters, and test the child-of-parent activation path before a production roll. The theme set is a repeatable, versioned asset like any other release, and treating it that way avoids the "which theme was live?" question during a site recovery.