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

  • From reading through the codex, this doesn't appear to be possible without some string manipulation. It looks like it used to be, but that stuff has been deprecated. Perhaps reconsider WHY you are looking for that slug? – RiaanP Mar 17 '16 at 11:17
  • I need it because I'm adding theme-specific styling to a plugin I built so need a unique identifier. – henrywright Mar 17 '16 at 11:21
  • @henrywright Theme specific goodies should be done in a child theme. Plugins are meant for site specific goodies ;-) – Pieter Goosen Mar 17 '16 at 11:47
  • @PieterGoosen That's a good rule of thumb but there are exceptions :P – henrywright Mar 17 '16 at 12:31
  • You have this information with get_stylesheet() – mmm Mar 17 '16 at 12:41

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

echo get_option('stylesheet');

Short Answer: get_stylesheet();

There is technically no 'slug' value for a theme. The name of a given theme's directory is what you want.


…will return the directory name of your theme, or the parent theme in the case that your current theme is a child theme.


Will ALWAYS return the directory name of your active theme, whether or not it is a child theme.


Will ALWAYS return the directory name of your active theme, whether or not it is a child theme. This function is essentially a wrapper for get_option('stylesheet');, except that it also applies a 'stylesheet' filter.

function get_stylesheet() {
 * Filters the name of current stylesheet.
 * @since 1.5.0
 * @param string $stylesheet Name of the current stylesheet.
return apply_filters( 'stylesheet', get_option( 'stylesheet' ) );

I'm not sure what the 'stylesheet' filter does. Looks like it might have something to do with the customizer.

In the vast majority of cases, these three functions would do the same thing, but get_stylesheet(); seems like the safest bet.


I found the closest thing to the theme's slug is the theme's directory name. This can be found using get_template():

echo get_template(); // twentyfifteen

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

  • 1
    That would catch the parent theme if there is one. – fuxia Mar 17 '16 at 13:40

wp_get_theme gets a WP_Theme object for a theme.

$theme = wp_get_theme();

if ( 'Conj' === $theme->name || 'conj' === $theme->template ) {
    // Do something...

i found this in wp-settings.php

// Load the functions for the active theme, for both parent and child theme if applicable.
foreach ( wp_get_active_and_valid_themes() as $theme ) {
    if ( file_exists( $theme . '/functions.php' ) ) {
        include $theme . '/functions.php';

Yo can get it by get_template_directory_uri()

  • Can you please explain how. get_template_directory_uri() returns a path, not a theme name – Pieter Goosen Mar 17 '16 at 12:17
  • Code should be in backticks or a code block. – Pieter Goosen Mar 17 '16 at 12:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.