Wordpress主题自定义程序-can';t添加节/设置


Wordpress theme customizer - can't add section/settings

我正试图通过添加部分和设置来修改Worpress主题自定义程序,但无论我在functions.php文件中添加了什么,自定义程序中都不会显示任何内容。

示例:

function starter_customize_register( $wp_customize ) 
{
    $wp_customize->add_section( 'mytheme_new_section_name' , array(
    'title'      => __( 'Visible Section Name', 'starter' ),
    'priority'   => 30, ) );    
}
add_action( 'customize_register', 'starter_customize_register');

我本以为这会添加一个具有选定名称的部分,但我只看到Wordpress的两个初始部分(网站标题和标语,静态首页)。

我在这里找到了一个非常好的教程(http://code.tutsplus.com/series/a-guide-to-the-wordpress-theme-customizer--wp-33722)。我遵循了每一步,甚至以他们的主题为例,但在那里,没有显示新的部分或设置。

这让我怀疑我的配置是否有问题。

我正在使用wordpress网络/多站点,不知道这是否相关。

知道吗?

谢谢Laurent

您需要添加设置和控件才能使其工作:

function starter_customize_register( $wp_customize ) 
{
    $wp_customize->add_section( 'starter_new_section_name' , array(
        'title'    => __( 'Visible Section Name', 'starter' ),
        'priority' => 30
    ) );   
    $wp_customize->add_setting( 'starter_new_setting_name' , array(
        'default'   => '#000000',
        'transport' => 'refresh',
    ) );
    $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'link_color', array(
        'label'    => __( 'Header Color', 'starter' ),
        'section'  => 'starter_new_section_name',
        'settings' => 'starter_new_setting_name',
    ) ) );
}
add_action( 'customize_register', 'starter_customize_register');

参考文献:主题定制API。