How to display theme information

Whether you are using one of WordPress’ default themes like Twenty Sixteen, you have downloaded a free one from the web or payed for the premium one, every theme will have basic information which is usually stored in style.css file. Even if you’re developing a theme from scratch, you will want to enter those information and give your theme a name, description and of course put your name as a signature directly into the files.

If you have browsed websites which offer different themes for download, you have probably seen extra information about them right next to their names and screenshots. If you want to do the same and show information about your theme, you can easily display all the necessary information by using this simple code.

  1. Open sidebar.php or any location where you want to show theme info
  2. Copy and paste the following code:
  3. $theme_data = wp_get_theme();
    echo $theme_data->get( 'Name' );
    echo $theme_data->get( 'ThemeURI' );
    echo $theme_data->get( 'Description' );
    echo $theme_data->get( 'Author' );
    echo $theme_data->get( 'AuthorURI' );
    echo $theme_data->get( 'Version' );
    echo $theme_data->get( 'Template' );
    echo $theme_data->get( 'Status' );
    echo $theme_data->get( 'Tags' );
    echo $theme_data->get( 'TextDomain' );
    echo $theme_data->get( 'DomainPath' );
    
  4. Choose information which you (don’t) want to display and delete rows if necessary
  5. Save changes

While you could have easily copied and pasted the information directly from the style.css file, this way you will always have the most current info about the theme. If you update the theme to a newer version, you won’t have to change the text manually (if you would even remember to do so) but the code will extract information automatically.

This is great if you want to show information about the currently active theme. But what if you want to show info about all the other themes you might have been using and have installed on your website? Don’t worry, you can easily modify the code to make that work.

In order to get data from another theme, you will need to insert its slug into the wp_get_theme brackets. For example, let’s get the data for Twenty Eleven which is currently not active on the site.

Show Twenty Eleven theme info:

$twentyeleven = wp_get_theme( 'twentyeleven' );
echo $twentyeleven->version;

This code will search for ‘twentlyeleven’ and then display its version. You can use all the other info from the theme following the given example.

Enjoy your theme info.

START YOUR OWN BLOG

This guide is an introduction to mastering the art of blogging. It provides easy to follow steps to start, maintain, and grow your blog.

Read the guide

Leave a Reply

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