8

One of the cool new features of WordPress 4.0 is the add_panel() method. In my situation, i'd like to create a new panel for theme options, that's very straight forward, but is it possible to create sub panels under the them options panel, for example one for the header, one for body and one for the footer? If so, how would I go about doing it?

12

You create Panels, and put Sections inside those Panels.

So if you have your panel:

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

Then you need to add your sections:

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

Regular sections are "sub" panels. Then you add your settings to your sections, and you are done.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.