As of wordpress 3.4 we’re supposed to use wp_get_theme to return theme data.
$theme = wp_get_theme();
//var_dump($theme);
echo $theme->Author;
despite the var_dump indicating the correct string, $theme->Author always returns a hyperlink with the author’s name, but linked to the author’s site. how can i get just the theme’s author name?
Do not use just the header string, call
display()
instead and set the second parameter toFALSE
to suppress markup.What you see in your
var_dump()
are private properties. If you print$theme->Author
the magic__get()
method is called and this callsdisplay()
without the second parameter for$markup
.Yes, you’re right. I could reproduce the issue on my WordPress 3.4.1 installation. Not sure if this is a bug; will need to dig into the core wordpress code to see how WP_Theme object is built and values are returned. For now, I think we’re left with an option to use PHP string Parser functions and extract Author name.