WordPress.org

Codex

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

Function Reference/add settings section

Description

Add a new section to a settings page.

Settings Sections are the groups of settings you see on WordPress settings pages with a shared heading. In your plugin you can add new sections to existing settings pages rather than creating a whole new page. This makes your plugin simpler to maintain and creates fewer new pages for users to learn. You just tell them to change your setting on the relevant existing page.

Usage

<?php add_settings_section$id$title$callback$page ); ?>

Parameters

$id
(string) (required) String for use in the 'id' attribute of tags.
Default: None
$title
(string) (required) Title of the section.
Default: None
$callback
(string) (required) Function that fills the section with the desired content. The function should echo its output.
Default: None
$page
(string) (required) The menu page on which to display this section. Should match $menu_slug from Function Reference/add theme page if you are adding a section to an 'Appearance' page, or Function Reference/add options page if you are adding a section to a 'Settings' page.
Default: None

Return Values

(void) 
This function does not return a value.

Notes

The callback function receives a single optional argument, which is an array with three elements. Example:

add_settings_section(
	'eg_setting_section',
	'Example settings section in reading',
	'eg_setting_section_callback_function',
	'reading'
);
function eg_setting_section_callback_function( $arg ) {
	// echo section intro text here
	echo '<p>id: ' . $arg['id'] . '</p>';             // id: eg_setting_section
	echo '<p>title: ' . $arg['title'] . '</p>';       // title: Example settings section in reading
	echo '<p>callback: ' . $arg['callback'] . '</p>'; // callback: eg_setting_section_callback_function
}

Change Log

Since: 2.7.0

Source File

add_settings_section() is located in wp-admin/includes/template.php.

Related

Settings API: register_setting(), unregister_setting(), add_settings_field(), add_settings_section(), add_settings_error(), get_settings_errors(), settings_errors()

See also index of Function Reference and index of Template Tags.