Are you looking for a way to display data from your WordPress theme file like name, title, URI, etc? While there’s probably a plugin for this, we have created a quick code snippet that you can use to display theme information with wp_get_theme
.
Instructions:
All you have to do is add this code to your theme’s functions.php file or in a site-specific plugin:
<?php $theme_data = wp_get_theme(); echo $theme_data->get( 'Name' ); // Theme name as given in style.css 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' ); ?>
Note: If this is your first time adding code snippets in WordPress, then please refer to our guide on how to properly add code snippets in WordPress, so you don’t accidentally break your site.
If you liked this code snippet, please consider checking out our other articles on the site like: 9 best WordPress real estate plugins and how to secure your WordPress forms with password protection.
This function has been deprecated. That means it has been replaced by a new function or is no longer supported
Thanks for the heads up, I updated the snippet, Cheers.
Hi Cliff, technically you could however that would not be a good way of doing things. I would suggest using something like jquery to let people change stylesheets. This tutorial should help you get started with that.
http://www.cssnewbie.com/simple-jquery-stylesheet-switcher/
I love this feature!
You can also call the css file by using get_stylesheet_uri() that way you don’t have to set the theme name:
$theme_data = get_theme_data(get_stylesheet_uri());
Ahh good call Gabriel ill have to update the post to include this method.