I’m able to get certain info about the active theme using wp_get_theme(). For example:

$theme = wp_get_theme();
echo $theme->get( 'TextDomain' ); // twentyfifteen
echo $theme->get( 'ThemeURI' ); // https://wordpress.org/themes/twentyfifteen/

Is there a way to get the theme’s slug? In this case it’d be twentyfifteen. Please note the theme’s slug isn’t always the same as the theme’s text domain. I’d also like to avoid performing string replacement on the theme’s URL if possible.

Ref: https://codex.wordpress.org/Function_Reference/wp_get_theme

6 s
6

You can get the slug in the options table, stored under the name stylesheet.

echo get_option('stylesheet');

Leave a Reply

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