我有一个解决办法
第一次创建节
// FRONT Page Settings settings.
$wp_customize->add_section(
\'betacoders_theme_front_page_options\',
array(
\'title\' => __(\' - Front Page Settings \', \'betacoders\'),
\'capability\' => \'edit_theme_options\',
\'description\' => __(\'FRONT Page Layout Options\', \'betacoders\'),
\'priority\' => 2,
)
);
// ==================================
// = Featured Categories SELECTOR =
// ==================================
$wp_customize->add_setting(\'featured_post\', array(
\'capability\' => \'edit_theme_options\',
\'type\' => \'option\',
));
// get categories list
$categories = get_categories(array(
\'orderby\' => \'name\',
\'order\' => \'ASC\',
\'hide_empty\' => 0,
// \'parent\' => 0,
// \'hierarchical\' => true
));
$cat_ids = array_map(function ($el) {
return $el->cat_ID;
}, $categories);
$cat_names = array_map(function ($el) {
return $el->cat_name;
}, $categories);
$wp_customize->add_control(\'mys_featured_post_ctrl\', [
\'label\' => \'Featured Post from Category\',
\'description\' => \'Featured Post from Category\',
\'section\' => \'betacoders_theme_front_page_options\',
\'settings\' => \'featured_post\',
// \'type\' => \'select\',
\'type\' => \'checkbox\',
\'choices\' => array() + array_combine($cat_ids, $cat_names) // combines all categories data
]);