wp_get_theme() works fine, but wp_get_themes() returns empty array

I am writing a code snippet for use in ManageWP, to extract some of the more basic audit info.

In the snippet, wp_get_theme() works fine, and returns correct info about the theme, and can be used to get parent theme info too.

BUT

I try to use wp_get_themes(), with no args, and it only returns an empty array.

Example code:

$theme_name = wp_get_theme()->get( ‘Name’ );
$theme_dir = get_stylesheet();
$parent_theme = $parent_dir = ”;
if ( is_object( wp_get_theme()->parent() ) ) {
$parent_theme = wp_get_theme()->parent()->name;
$parent_dir = get_template();
}
$all_themes = wp_get_themes();
print_r( $all_themes );

Array
(
)

Recommendations?

Read more here:: wp_get_theme() works fine, but wp_get_themes() returns empty array

Leave a Reply

Your email address will not be published. Required fields are marked *