我试图通过添加节和设置来修改WordPress主题定制器,但无论我在functions.php
文件,自定义程序中不会显示任何内容。
这是我的代码:-
function starter_customize_register( $wp_customize )
{
$wp_customize->add_panel( \'home_page_settings\', array(
\'title\' => __( \'Home Page Settings\', \'starter\'),
\'priority\' => 10,
\'active_callback\' => \'is_front_page\'
) );
$wp_customize->add_section( \'home_call_to_action_section\' , array(
\'title\' => __(\'Call To Action\',\'starter\'),
\'panel\' => \'home_page_settings\',
) );
$wp_customize->add_setting( \'home_call_to_action_setting_section\', array(
\'default\' => __(\'WHAT IS RO PURIFIER?\', \'starter\'),
\'sanitize_callback\' => \'starter_sanitize\',
));
$wp_customize->add_control(\'cta_heading\', array(
\'label\' => __(\'CTA Heading\',\'starter\'),
\'section\' => \'home_call_to_action_section\',
\'setting\'=>\'home_call_to_action_setting_section\'
));
}
add_action( \'customize_register\', \'starter_customize_register\');
提前感谢。。
SO网友:cjbj
您对的使用add_control
不正确。更具体地说,您没有说明要添加什么类型的控件。请参阅codex链接,查看哪些类型可以自动生成。我在下面给出了一个文本字段示例。
$wp_customize->add_control(\'cta_heading\', array(
\'label\' => __(\'CTA Heading\',\'starter\'),
\'section\' => \'home_call_to_action_section\',
\'setting\'=>\'home_call_to_action_setting_section\',
\'type\'=>\'text\',
));
请注意,如果需要更复杂的控件,如颜色,则需要显式创建控件对象。codex链接中也给出了一个示例。