WordPress.org

Ready to get started?Download WordPress

Forums

Getting name of current theme (3 posts)

  1. AndWat
    Member
    Posted 9 years ago #

    I want to display the name of the theme currently in use. So I have (in sidebar.php) a call to the function get_current_theme(). But it always seems to display the name of the default theme, even when I theme-switch to a different theme.

    I can't find any documentation on get_current_theme. Does it actually get the theme currently in use by the blog? If so, what is it that I'm missing, thus preventing the display of the right theme name?

    Thanks for any help,
    Andrew
    changingway.net

  2. Kafkaesqui

    Posted 9 years ago #

    Here's the code I presently use in my themes:

    <?php
    if (!empty($_COOKIE["wptheme" . COOKIEHASH]))
    $theme_name = $_COOKIE["wptheme" . COOKIEHASH];
    else
    $theme_name = get_current_theme();
    ?>

    <?php echo $theme_name; ?>

    This works if using Ryan's ThemeSwitcher plugin (you may need to modify $_COOKIE for others). If you want to get additional info on the theme, add this to the end of the first code block:

    $theme = get_theme("$theme_name");

    And call it like so:

    <?php echo $theme['Author'];?>

  3. AndWat
    Member
    Posted 9 years ago #

    Again, K, I thank you. It works fine. And thanks for the bonus info also.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.