• Skip to primary navigation
  • Skip to main content
Sal Ferrarello
  • About Sal Ferrarello
  • Speaking
  • Connect
    Mastodon GitHub Twitter (deprecated)
You are here: Home / Dev Tips / WP CLI Get Current Theme

WP CLI Get Current Theme

Last updated on October 30, 2024 by Sal Ferrarello

I thought retrieving the currently active theme on a WordPress website with WP CLI would involve the wp theme command but I was wrong. The correct command to get the currently active theme is wp option get current_theme.

Example

$ wp option get current_theme
Bootstrap4 Genesis

What You Can Get from wp theme

When we run wp theme list

+----------------------+----------+--------+---------+----------------+-------------+
| name                 | status   | update | version | update_version | auto_update |
+----------------------+----------+--------+---------+----------------+-------------+
| bootstrap4-genesis   | active   | none   | 1.3.2   |                | off         |
| genesis              | parent   | none   | 3.5.0   |                | off         |
| twentytwentyfour     | inactive | none   | 1.2     |                | off         |
+----------------------+----------+--------+---------+----------------+-------------+

We can see the active theme but it isn’t easy to grab it programmatically (though we can grab it by setting the output to json and using the jq utility, see following example).

Thanks for calling this out Ryan Neilson.

Alternative Command to Retrieve Current Theme

wp theme list --status=active --format=json | jq '.[0].name'

Get List of Active Themes in a WordPress Multisite

This is a helpful command based on Loop Through WordPress Multisite Blogs with WP CLI to display all of the site names and the active theme on that site.

for URL in $(wp site list --field=url); do 
  wp option get blogname --url=$URL;
  wp option get current_theme --url=$URL;
  echo "-----------------------------";
done
Sal Ferrarello
Sal Ferrarello (@salcode)
Sal is a PHP and JavaScript developer with a focus on the WordPress platform. He is a conference speaker with a background including Piano Player, Radio DJ, Magician/Juggler, Beach Photographer, and High School Math Teacher. Sal can be found professionally at WebDevStudios, where he works as a principal engineer.

Filed Under: Computing, Dev Tips, Solution Tagged With: WordPress, WordPress Theme, wp-cli

Reader Interactions

Comments

  1. Felipe Elia says

    January 10, 2025 at 7:44 am

    You could use `wp theme list –status=active –field=title`, no?

    Reply
    • Sal Ferrarello says

      January 19, 2025 at 5:11 pm

      Thanks Felipe!

      You’re right, both

      wp theme list –status=active –field=title

      to get the title and

      wp theme list –status=active –field=name

      to get the name (i.e. the same value I was getting with wp option get current_theme) work!

      I’ll need to update this article.

      Thank you!

      Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Copyright © 2026 · Bootstrap4 Genesis on Genesis Framework · WordPress · Log in