自定义选项-在同一部分下添加两个图像上传程序

时间:2015-05-23 作者:crazymoin

为了添加上载选项,我在函数页上添加了以下代码:

add_action( \'customize_register\', \'custom_logo_uploader\' );
function custom_logo_uploader($wp_customize) {

    $wp_customize->add_section( \'upload_custom_logo\', array(
        \'title\'          => \'Logo\',
        \'description\'    => \'Display a custom logo?\',
        \'priority\'       => 25,
    ) );

    $wp_customize->add_setting( \'custom_logo\', array(
        \'default\'        => \'\',
    ) );

    $wp_customize->add_control( new WP_Customize_Image_Control( $wp_customize, \'custom_logo\', array(
        \'label\'   => \'Custom logo\',
        \'section\' => \'upload_custom_logo\',
        \'settings\'   => \'custom_logo\',
    ) ) );
}
我的问题是如何在同一节中添加多个图片选项?

1 个回复
最合适的回答,由SO网友:crazymoin 整理而成

所以,在整个搜索之后,我找到了解决方案。添加新设置并添加新控件。在控件内部,添加新

add_action( \'customize_register\', \'custom_logo_uploader\' );
function custom_logo_uploader($wp_customize) {

    $wp_customize->add_section( \'upload_custom_logo\', array(
        \'title\'          => \'Logo\',
        \'description\'    => \'Display a custom logo?\',
        \'priority\'       => 25,
    ) );

    $wp_customize->add_setting( \'custom_logo\', array(
        \'default\'        => \'\',
    ) );

    $wp_customize->add_control( new WP_Customize_Image_Control( $wp_customize, \'custom_logo\', array(
        \'label\'   => \'Custom logo\',
        \'section\' => \'upload_custom_logo\',
        \'settings\'   => \'custom_logo\',
    ) ) );

    $wp_customize->add_setting( \'custom_logo2\', array(
        \'default\'        => \'\',
    ) );

    $wp_customize->add_control( new WP_Customize_Image_Control( $wp_customize, \'custom_logo2\', array(
        \'label\'   => \'Custom logo\',
        \'section\' => \'upload_custom_logo\', // put the name of whatever section you want to add your settings
        \'settings\'   => \'custom_logo2\',
    ) ) );
}
对不起,如果我把我糟糕的英语弄糊涂了(

结束

相关推荐

Admin Theme customization

我遵循wordpress codex网站上关于通过插件创建管理主题的说明。我激活了插件,但我的样式表没有包含在<head>.. 这是我的代码:add_action( \'admin_init\', \'kd_plugin_admin_init\' ); add_action( \'admin_menu\', \'kd_plugin_admin_menu\' ); function kd_plugin_admin_init() { /* Register