【发布时间】:2022-12-09 14:21:54
【问题描述】:
我是 Wordpress 主题开发的初学者,正在学习定制器 API。 但是,我被困在尝试使用 Customizer API 来使用 WordPress Customizer 更改导航菜单背景颜色的地方,但它没有显示任何内容,尽管我已经根据我的知识包含了所有必要的行。这是我试图在内部实现的代码 - functions.php:
function textdomain_pro_theme($wp_customize) {
$wp_customize->add_panel( 'pro_features', array(
'title' => 'Pro Features',
'priority' => 10
));
$wp_customize->add_section( 'color_picking' , array(
'title' => 'Color Settings',
'panel' => 'pro_features',
'priority' => 30
));
$wp_customize->add_setting( 'nav_menu_bgcolor', array(
'type' => 'theme_mod',
'capability' => 'edit_theme_options',
'default' => '#ff2525',
'transport' => 'refresh',
'sanitize_callback' => 'sanitize_hex_color',
));
$wp_customize->add_control( 'nav_menu_bgcolor', array(
'label' => 'Navigation Bar Color',
'type' => 'color',
'section' => 'pro_features',
));
}
add_action( 'customize_register', 'textdomain_pro_theme' );
CUSTOMIZER 不显示新部分。什么地方出了错?
我当前的 WORDPRESS 版本是 6.1
【问题讨论】:
标签: php wordpress wordpress-theming