Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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?

share|improve this question
    
I just upgraded to 3.4.1 to check this issue but i got just author's name and no hyperlink $theme = wp_get_theme(); var_dump($theme->Author); this is what i got: > string 'the WordPress team' (length=18) –  HungryCoder Jul 1 '12 at 9:18

2 Answers 2

up vote 4 down vote accepted

Do not use just the header string, call display() instead and set the second parameter to FALSE to suppress markup.

// FALSE for no markup
$theme->display( 'Author', FALSE );

What you see in your var_dump() are private properties. If you print $theme->Author the magic __get() method is called and this calls display() without the second parameter for $markup.

share|improve this answer
    
thanks toscho... that does it. i guess i have a lot to learn about OOP and "private" properties. –  helgatheviking Jul 1 '12 at 15:13

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.