If you look at how the code works, 你应该注意到主题mod保存在*_options
下的表格theme_mods_{theme_slug}
主题slug是包含主题样式表的目录名,因此:
$ptheme = get_template_directory();
$theme_slug = basename($ptheme);
$mods = get_option( "theme_mods_$theme_slug");
作为一种功能:
function get_parent_theme_mods($mod = \'\') {
$ptheme = get_template_directory();
$theme_slug = basename($ptheme);
$mods = get_option( "theme_mods_{$theme_slug}");
if (!empty($mods) && isset($mods[$mod])) {
$mods = $mods[$mod];
}
return $mods;
}
var_dump(get_parent_theme_mods());
var_dump(get_parent_theme_mods(\'background_color\'));