这不是一个完整的解决方案,代码也没有经过测试,但我认为这应该足以让您大致了解如何在不同的页面上使用定制器。
// Add "Edit page with customizer" link to relevant pages
add_action(\'admin_bar_menu\', function($bar) {
if (is_home()) {
$bar->add_node(array(
\'id\' => \'some-id-1\',
\'title\' => \'Edit home page with customizer\',
\'href\' => admin_url( \'customize.php?url=/home\'),
));
}
else {
// Same as above, but change url=/home to some other page
// and possibly add something like &customize-page-id=PAGE_ID
// so that you can use the page id later.
}
});
// Add customizer settings based on context passed from admin-bar
add_action( \'customize_register\', function() {
if ($_GET[\'url\'] == \'/home\') {
// Add home page customizers
}
else {
// Add other page customizer where setting names are based on
// $_GET[\'customize-page-id\'] so that to avoid conflicts
}
});
});