WordPress.org

Codex

Attention Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

Class Reference/WP Customize Manager/add section

Description

Adds a new section to the Theme Customization admin screen. Sections are convenient ways to group controls logically.

This is a method of the WP_Customize_Manager class and can only be accessed through the $wp_customize object within the customize_register action hook.

Usage

$wp_customize->add_section($id, $args);

Parameters

$id
(string) (required) A unique slug-like string to use as an id.
Default: None
$args
(array) (required) An associative array containing arguments for the control.
Default: None

Arguments

title
The visible name of a controller section.
priority
This controls the order in which this section appears in the Theme Customizer sidebar.
description
This optional argument can add additional descriptive text to the section.
active_callback
This optional argument can show or hide section based on currently viewed page. Example: 'active_callback' => 'is_front_page'.

Default Sections

WordPress does include a few built-in sections. If you want to use any of the existing, built-in ones, you don't need to declare them with add_section(). Instead, refer to them directly. The following sections are built-in...

  • title_tagline - Site Title & Tagline
  • colors - Colors
  • header_image - Header Image
  • background_image - Background Image
  • nav - Navigation
  • static_front_page - Static Front Page

Example

Adding a theme section (within the 'customize_register' action) might look like this:

$wp_customize->add_section( 'mytheme_new_section_name' , array(
    'title'      => __('Visible Section Name','mytheme'),
    'priority'   => 30,
) );

Related

See also index of Class Reference and index of Function Reference.