Skip to content

Instantly share code, notes, and snippets.

@hsleonis
Created April 3, 2016 12:04
Show Gist options
  • Select an option

  • Save hsleonis/a02ad535df9ee2ce43b794936f941ed3 to your computer and use it in GitHub Desktop.

Select an option

Save hsleonis/a02ad535df9ee2ce43b794936f941ed3 to your computer and use it in GitHub Desktop.
Gets a WP_Theme object for a theme
<?php
/**
* Gets a WP_Theme object for a theme
* Reference: https://developer.wordpress.org/reference/functions/wp_get_theme
*/
// Echo the name of the current active theme
echo wp_get_theme();
// Echo the name of an installed theme
$my_theme = wp_get_theme( 'twentytwelve' );
if ( $my_theme->exists() )
echo esc_html( $my_theme );
// Display the current theme’s version
$my_theme = wp_get_theme();
printf( "%1$s is version %2$s",
$my_theme->get( 'Name' ),
$my_theme->get( 'Version' )
);
// Display the current theme author URI
$my_theme = wp_get_theme();
echo esc_html( $my_theme->get( 'AuthorURI' ) );
// Get other data: Text domain & theme URI
$my_theme = wp_get_theme();
echo esc_html( $my_theme->get( 'TextDomain' ) );
echo esc_html( $my_theme->get( 'ThemeURI' ) );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment