如何创建一个主题定制器‘子’面板?

时间:2014-11-30 作者:Zach Russell

WordPress 4.0最酷的新特性之一是add_panel() 方法在我的情况下,我想为主题选项创建一个新面板,这很简单,但是否可以在它们选项面板下创建子面板,例如一个用于页眉,一个用于正文,一个用于页脚?如果是这样的话,我该怎么做呢?

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

您可以创建面板,并在这些面板中放置剖面。

因此,如果您有面板:

$wp_customize->add_panel( \'panel_id\', array(
 \'priority\'       => 10,
  \'capability\'     => \'edit_theme_options\',
  \'theme_supports\' => \'\',
  \'title\'          => __(\'Theme Options\', \'mytheme\'),
  \'description\'    => __(\'Several settings pertaining my theme\', \'mytheme\'),
) );
然后,您需要添加分区:

$wp_customize->add_section( \'header_settings\', array(
    \'priority\'       => 10,
    \'capability\'     => \'edit_theme_options\',
    \'theme_supports\' => \'\',
    \'title\'          => __(\'Header Settings\', \'mytheme\'),
    \'description\'    =>  __(\'Header elements configuration\', \'mytheme\'),
    \'panel\'  => \'panel_id\',
) );

$wp_customize->add_section( \'footer_settings\', array(
    \'priority\'       => 10,
    \'capability\'     => \'edit_theme_options\',
    \'theme_supports\' => \'\',
    \'title\'          => __(\'Footer Settings\', \'mytheme\'),
    \'description\'    =>  __(\'Footer elements configuration\', \'mytheme\'),
    \'panel\'  => \'panel_id\',
) );
常规截面为“子”面板。然后将设置添加到分区中,就完成了。

结束

相关推荐