有没有办法在主题定制器中创建深层子面板(如植物的根)?我一直在发展的主题似乎更加复杂。我认为,如果我们能够创建深层次的子面板,我们的定制页面将不会看起来凌乱,我们的用户将更容易定制主题,我们将能够使更复杂的WordPress主题更容易。下面的图片描述了我的想法。。。
不幸的是,我已经尝试过搜索这个主题,但我只能找到在主题定制器中创建单层面板的方法another thread , 无法找到使子面板更深的方法。你能为我的生活遮光吗?
Update : 下面的代码是我用来创建面板和控件的一些代码,如image#1,它是单层面板。它们都很好用。
$wp_customize->add_panel(\'panel1\',
array(
\'title\' => \'Panel 1\',
\'priority\' => 1,
)
);
$wp_customize->add_section( \'section1\',
array(
\'title\' => \'This is section 1\',
\'priority\' => 1,
\'panel\' => \'panel1\'
)
);
$wp_customize->add_setting(\'field1\', array(\'default\' => \'default text\'));
$wp_customize->add_control(\'field1\', array(
\'label\' => \'Text field\',
\'section\' => \'section1\',
\'type\' => \'text\',
)
);
我的问题是,我想创建一个新的面板,让它们粘在另一个面板上,这将使它看起来像根层次结构(图#2)。我认为,如果我们可以这样做,我们将能够制作更强大的主题定制器。然后我试图实现这个想法,并试图重写我的代码。不幸的是,它没有起作用。请检查下面的一个。
$wp_customize->add_panel(\'panel1\',
array(
\'title\' => \'Panel 1\',
\'priority\' => 1,
)
);
$wp_customize->add_section( \'section1\',
array(
\'title\' => \'This is section 1\',
\'priority\' => 1,
\'panel\' => \'panel1\'
)
);
$wp_customize->add_setting(\'field1\', array(\'default\' => \'default text\'));
$wp_customize->add_control(\'field1\', array(
\'label\' => \'Text field\',
\'section\' => \'section1\',
\'type\' => \'text\',
)
);
// I used the code below with a little hope that it will help me accomplish my idea, but it didn\'t work T^T.
$wp_customize->add_panel(\'panel1_1\',
array(
\'title\' => \'Panel 1.1\',
\'priority\' => 2,
\'panel\' => \'panel1\' // I tried adding this line of code in order to let it depend on another panel
)
);
$wp_customize->add_section( \'section1_1\',
array(
\'title\' => \'This is section 1\',
\'priority\' => 1,
\'panel\' => \'panel1_1\'
)
);
$wp_customize->add_setting(\'field1_1\', array(\'default\' => \'default text\'));
$wp_customize->add_control(\'field1_1\', array(
\'label\' => \'Text field\',
\'section\' => \'section1_1\',
\'type\' => \'text\',
)
);
你能给我一个解决方案吗?我不知道如何使面板看起来像根层次结构。任何帮助都将不胜感激:)