如何创建主题定制器“子”面板?


8

add_panel()方法是WordPress 4.0的一项很酷的新功能。在我的情况下,我想为主题选项创建一个新面板,这很简单,但是可以在它们的选项面板下创建子面板,例如,一个用于标题,一个用于主体,一个用于页脚?如果是这样,我将如何去做?

Answers:


12

创建面板,然后将“节”放入这些面板中。

因此,如果您有小组讨论:

$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',
) );

常规部分是“子”面板。然后,将您的设置添加到您的部分中,就可以完成。


嘿@yivi,您知道如何创建类似wordpress.stackexchange.com/questions/199427/…这样的问题的多层面板吗?谢谢 !
董林潘
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.