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)

The safe activation order

  1. Take a pre-change snapshot of the relevant state: wp option get template and wp option get stylesheet (or wp theme list) tell you both what is active and what the previous value was.
  2. Install in staging first if the theme is new; wp theme install on staging avoids polluting production with a half-tested theme.
  3. Activate on the live site with wp theme activate <slug>.
  4. Verify instantly: wp theme list again 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.
  5. Keep the fallback ready: the default theme (twenty-*) is usually still installed, so wp theme activate twentytwentyfour is 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

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.

Need a website built, fixed, optimised, migrated or replaced?

This technical resource is written by CSMBAC, a small design and development studio. If you would rather hand the problem to a professional, the website service page explains how we build enquiry-ready websites.

Explore website services