我试图遍历已安装的Wordpress主题以提取数据。我需要访问$ value-> headers [“ TextDomain”],但是当我尝试访问$ value-> headers时,我得到一个NULL
响应。
这是我要从中提取数据的Wordpress主题对象数组:
object(WP_Theme)#795 (12) {
["update"]=>
bool(false)
["theme_root":"WP_Theme":private]=>
string(56) "/Users/tygoss/Projects/QuickPress/prod/wp-content/themes"
["headers":"WP_Theme":private]=>
array(11) {
["Name"]=>
string(10) "Black Jane"
["ThemeURI"]=>
string(0) ""
["Description"]=>
string(187) "Black Jane is a clean SuevaFree child theme with an optional slideshow on homepage, a new header layout in addition to the five header layouts available on SuevaFree and new Google Fonts."
["Author"]=>
string(16) "ThemeinProgress."
["AuthorURI"]=>
string(31) "https://www.themeinprogress.com"
["Version"]=>
string(5) "1.0.4"
["Template"]=>
string(9) "suevafree"
["Status"]=>
string(0) ""
["Tags"]=>
string(302) "blog, e-commerce, photography, custom-background, custom-colors, custom-header, custom-logo, custom-menu, featured-images, flexible-header, footer-widgets, post-formats, right-sidebar, sticky-post, theme-options, threaded-comments, translation-ready, one-column, two-columns, three-columns, grid-layout"
["TextDomain"]=>
string(10) "black-jane"
["DomainPath"]=>
string(10) "/languages"
}
["name_translated":"WP_Theme":private]=>
NULL
["errors":"WP_Theme":private]=>
NULL
["stylesheet":"WP_Theme":private]=>
string(10) "black-jane"
["template":"WP_Theme":private]=>
string(9) "suevafree"
}
如果我var_dump($ value-> stylesheet)我得到string(10) "black-jane"
但是如果我var_dump($ value-> headers)我得到NULL
这是我的循环:
$all_themes = wp_get_themes();
foreach ($all_themes as $key => $value) {
echo '<pre>';
var_dump($value->headers);
echo '</pre>';
}
$ value->标头不应该丢弃11个项目的数组吗?为什么返回NULL
,为什么$ value-> stylesheet起作用但$ value-headers不起作用?
答案 0 :(得分:0)
$value->get("the thing from the header array")
完美运行!