WordPress定制器子部分

时间:2015-10-12 14:51:26

标签: wordpress

我试图在WordPress中的自定义选项中创建一个子部分,所以我有一个名为Typography的新部分,我想在其中创建标题为Heading 1,Heading 2等的子部分...那些应该打开进入他们自己的一套控件。但是,我一直在查看手抄本,似乎无法找到一种方法来链接这些菜单,任何想法?

以下是添加部分的常规代码,但添加新部分似乎没有将其附加到父级的选项?我已经尝试了下面的代码的一些变化而没有任何运气,我得到的是主菜单上的2个排版菜单。

编辑:仍然没有运气,我在法典中读到有关面板的选项,但似乎无法实现它。

我正在使用下面的代码,它只是代码的简化版本,以确保我正确。我假设一个部分进入面板,设置和控制进入该部分。使用此codex

// ADD PANEL
$wp_customize->add_panel( 'typography_panel', array(
'priority'       => 10,
'capability'     => 'edit_theme_options',
'theme_supports' => '',
'title'          => 'Typography',
'description'    => 'contains options for all font settings on the website.',
) );

// ADD SECTION TO GO INTO PANEL
$wp_customize->add_section( 'heading_1', array(
'priority'       => 20,
'capability'     => 'edit_theme_options',
'theme_supports' => '',
'title'          => 'H1 Options',
'description'    => 'all options for heading 1 font.',
'panel'  => 'typography_panel',
) );

// ADD SETTINGS
// Selector Background - Highlighting
$wp_customize->add_setting(
        'typography_highlight_background_h1',
        array(
        'default' => '#333948',
        'sanitize_callback' => '',
    ) );

// ADD CONTROLS
// Highlight Background for Browser
$wp_customize->add_control( 
    new WP_Customize_Color_Control( 
        $wp_customize, 'typography_highlight_background_h1', 
        array(
        'label'      => __( 'Highlight Background', 'typography_highlight_background_h1' ),
        'section'    => 'heading_1',
        'settings'   => 'typography_highlight_background_h1',
) ) );

1 个答案:

答案 0 :(得分:0)

您正在寻找add_settingadd_control。可以通过将节的名称作为参数传递给{{ Form::open(['route' => ['search', $subreddit->getRouteKey()]]) }} 来添加子节。