Using wp_get_theme returns an object holding the properties of the current theme. The headers property contains any array of information I wish to access.

I can access the other properties using normal notation


When I try


I get NULL

How can I access the array within the headers property? Below is a var_dump of wp_get_theme()

object(WP_Theme)#381 (11) {
  string(14) "/path/to/theme"
  array(11) {
    string(9) "Site Name"
    string(0) ""
    string(11) "Description"

You cannot access the $headers property as it is a private property.

Members declared as private may only be accessed by the class that defines the member

For that reason, you get NULL when you try to access the property with wp_get_theme()->headers. You need to make use of the magic __get() method of the class to get the info you are after.

Example: (From the codex page, wp_get_theme())

$my_theme = wp_get_theme();
echo $my_theme->get( 'TextDomain' );
echo $my_theme->get( 'ThemeURI' );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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