Created
April 3, 2016 12:04
-
-
Save hsleonis/a02ad535df9ee2ce43b794936f941ed3 to your computer and use it in GitHub Desktop.
Gets a WP_Theme object for a theme
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?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