Getting headers property from WP_Theme object

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())

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

Leave a Comment