add_settings_section

The timeline below displays how wordpress function add_settings_section has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 6.1

/**
 * Adds a new section to a settings page.
 *
 * Part of the Settings API. Use this to define new settings sections for an admin page.
 * Show settings sections in your admin page callback function with do_settings_sections().
 * Add settings fields to your section with add_settings_field().
 *
 * The $callback argument should be the name of a function that echoes out any
 * content you want to show at the top of the settings section before the actual
 * fields. It can output nothing if you want.
 *
 * @since 2.7.0
 * @since 6.1.0 Added an `$args` parameter for the section's HTML wrapper and class name.
 *
 * @global array $wp_settings_sections Storage array of all settings sections added to admin pages.
 *
 * @param string   $id       Slug-name to identify the section. Used in the 'id' attribute of tags.
 * @param string   $title    Formatted title of the section. Shown as the heading for the section.
 * @param callable $callback Function that echos out any content at the top of the section (between heading and fields).
 * @param string   $page     The slug-name of the settings page on which to show the section. Built-in pages include
 *                           'general', 'reading', 'writing', 'discussion', 'media', etc. Create your own using
 *                           add_options_page();
 * @param array    $args     {
 *     Arguments used to create the settings section.
 *
 *     @type string $before_section HTML content to prepend to the section's HTML output.
 *                                  Receives the section's class name as `%s`. Default empty.
 *     @type string $after_section  HTML content to append to the section's HTML output. Default empty.
 *     @type string $section_class  The class name to use for the section. Default empty.
 * }
 */
function add_settings_section($id, $title, $callback, $page, $args = array())
{
    global $wp_settings_sections;
    $defaults = array('id' => $id, 'title' => $title, 'callback' => $callback, 'before_section' => '', 'after_section' => '', 'section_class' => '');
    $section = wp_parse_args($args, $defaults);
    if ('misc' === $page) {
        _deprecated_argument(__FUNCTION__, '3.0.0', sprintf(
            /* translators: %s: misc */
            __('The "%s" options group has been removed. Use another settings group.'),
            'misc'
        ));
        $page = 'general';
    }
    if ('privacy' === $page) {
        _deprecated_argument(__FUNCTION__, '3.5.0', sprintf(
            /* translators: %s: privacy */
            __('The "%s" options group has been removed. Use another settings group.'),
            'privacy'
        ));
        $page = 'reading';
    }
    $wp_settings_sections[$page][$id] = $section;
}

WordPress Version: 5.5

/**
 * Add a new section to a settings page.
 *
 * Part of the Settings API. Use this to define new settings sections for an admin page.
 * Show settings sections in your admin page callback function with do_settings_sections().
 * Add settings fields to your section with add_settings_field().
 *
 * The $callback argument should be the name of a function that echoes out any
 * content you want to show at the top of the settings section before the actual
 * fields. It can output nothing if you want.
 *
 * @since 2.7.0
 *
 * @global array $wp_settings_sections Storage array of all settings sections added to admin pages.
 *
 * @param string   $id       Slug-name to identify the section. Used in the 'id' attribute of tags.
 * @param string   $title    Formatted title of the section. Shown as the heading for the section.
 * @param callable $callback Function that echos out any content at the top of the section (between heading and fields).
 * @param string   $page     The slug-name of the settings page on which to show the section. Built-in pages include
 *                           'general', 'reading', 'writing', 'discussion', 'media', etc. Create your own using
 *                           add_options_page();
 */
function add_settings_section($id, $title, $callback, $page)
{
    global $wp_settings_sections;
    if ('misc' === $page) {
        _deprecated_argument(__FUNCTION__, '3.0.0', sprintf(
            /* translators: %s: misc */
            __('The "%s" options group has been removed. Use another settings group.'),
            'misc'
        ));
        $page = 'general';
    }
    if ('privacy' === $page) {
        _deprecated_argument(__FUNCTION__, '3.5.0', sprintf(
            /* translators: %s: privacy */
            __('The "%s" options group has been removed. Use another settings group.'),
            'privacy'
        ));
        $page = 'reading';
    }
    $wp_settings_sections[$page][$id] = array('id' => $id, 'title' => $title, 'callback' => $callback);
}

WordPress Version: 5.3

/**
 * Add a new section to a settings page.
 *
 * Part of the Settings API. Use this to define new settings sections for an admin page.
 * Show settings sections in your admin page callback function with do_settings_sections().
 * Add settings fields to your section with add_settings_field().
 *
 * The $callback argument should be the name of a function that echoes out any
 * content you want to show at the top of the settings section before the actual
 * fields. It can output nothing if you want.
 *
 * @since 2.7.0
 *
 * @global $wp_settings_sections Storage array of all settings sections added to admin pages.
 *
 * @param string   $id       Slug-name to identify the section. Used in the 'id' attribute of tags.
 * @param string   $title    Formatted title of the section. Shown as the heading for the section.
 * @param callable $callback Function that echos out any content at the top of the section (between heading and fields).
 * @param string   $page     The slug-name of the settings page on which to show the section. Built-in pages include
 *                           'general', 'reading', 'writing', 'discussion', 'media', etc. Create your own using
 *                           add_options_page();
 */
function add_settings_section($id, $title, $callback, $page)
{
    global $wp_settings_sections;
    if ('misc' == $page) {
        _deprecated_argument(__FUNCTION__, '3.0.0', sprintf(
            /* translators: %s: misc */
            __('The "%s" options group has been removed. Use another settings group.'),
            'misc'
        ));
        $page = 'general';
    }
    if ('privacy' == $page) {
        _deprecated_argument(__FUNCTION__, '3.5.0', sprintf(
            /* translators: %s: privacy */
            __('The "%s" options group has been removed. Use another settings group.'),
            'privacy'
        ));
        $page = 'reading';
    }
    $wp_settings_sections[$page][$id] = array('id' => $id, 'title' => $title, 'callback' => $callback);
}

WordPress Version: 5.1

/**
 * Add a new section to a settings page.
 *
 * Part of the Settings API. Use this to define new settings sections for an admin page.
 * Show settings sections in your admin page callback function with do_settings_sections().
 * Add settings fields to your section with add_settings_field().
 *
 * The $callback argument should be the name of a function that echoes out any
 * content you want to show at the top of the settings section before the actual
 * fields. It can output nothing if you want.
 *
 * @since 2.7.0
 *
 * @global $wp_settings_sections Storage array of all settings sections added to admin pages.
 *
 * @param string   $id       Slug-name to identify the section. Used in the 'id' attribute of tags.
 * @param string   $title    Formatted title of the section. Shown as the heading for the section.
 * @param callable $callback Function that echos out any content at the top of the section (between heading and fields).
 * @param string   $page     The slug-name of the settings page on which to show the section. Built-in pages include
 *                           'general', 'reading', 'writing', 'discussion', 'media', etc. Create your own using
 *                           add_options_page();
 */
function add_settings_section($id, $title, $callback, $page)
{
    global $wp_settings_sections;
    if ('misc' == $page) {
        _deprecated_argument(
            __FUNCTION__,
            '3.0.0',
            /* translators: %s: misc */
            sprintf(__('The "%s" options group has been removed. Use another settings group.'), 'misc')
        );
        $page = 'general';
    }
    if ('privacy' == $page) {
        _deprecated_argument(
            __FUNCTION__,
            '3.5.0',
            /* translators: %s: privacy */
            sprintf(__('The "%s" options group has been removed. Use another settings group.'), 'privacy')
        );
        $page = 'reading';
    }
    $wp_settings_sections[$page][$id] = array('id' => $id, 'title' => $title, 'callback' => $callback);
}

WordPress Version: 4.8

/**
 * Add a new section to a settings page.
 *
 * Part of the Settings API. Use this to define new settings sections for an admin page.
 * Show settings sections in your admin page callback function with do_settings_sections().
 * Add settings fields to your section with add_settings_field()
 *
 * The $callback argument should be the name of a function that echoes out any
 * content you want to show at the top of the settings section before the actual
 * fields. It can output nothing if you want.
 *
 * @since 2.7.0
 *
 * @global $wp_settings_sections Storage array of all settings sections added to admin pages
 *
 * @param string   $id       Slug-name to identify the section. Used in the 'id' attribute of tags.
 * @param string   $title    Formatted title of the section. Shown as the heading for the section.
 * @param callable $callback Function that echos out any content at the top of the section (between heading and fields).
 * @param string   $page     The slug-name of the settings page on which to show the section. Built-in pages include
 *                           'general', 'reading', 'writing', 'discussion', 'media', etc. Create your own using
 *                           add_options_page();
 */
function add_settings_section($id, $title, $callback, $page)
{
    global $wp_settings_sections;
    if ('misc' == $page) {
        _deprecated_argument(
            __FUNCTION__,
            '3.0.0',
            /* translators: %s: misc */
            sprintf(__('The "%s" options group has been removed. Use another settings group.'), 'misc')
        );
        $page = 'general';
    }
    if ('privacy' == $page) {
        _deprecated_argument(
            __FUNCTION__,
            '3.5.0',
            /* translators: %s: privacy */
            sprintf(__('The "%s" options group has been removed. Use another settings group.'), 'privacy')
        );
        $page = 'reading';
    }
    $wp_settings_sections[$page][$id] = array('id' => $id, 'title' => $title, 'callback' => $callback);
}

WordPress Version: 4.6

/**
 * Add a new section to a settings page.
 *
 * Part of the Settings API. Use this to define new settings sections for an admin page.
 * Show settings sections in your admin page callback function with do_settings_sections().
 * Add settings fields to your section with add_settings_field()
 *
 * The $callback argument should be the name of a function that echoes out any
 * content you want to show at the top of the settings section before the actual
 * fields. It can output nothing if you want.
 *
 * @since 2.7.0
 *
 * @global $wp_settings_sections Storage array of all settings sections added to admin pages
 *
 * @param string   $id       Slug-name to identify the section. Used in the 'id' attribute of tags.
 * @param string   $title    Formatted title of the section. Shown as the heading for the section.
 * @param callable $callback Function that echos out any content at the top of the section (between heading and fields).
 * @param string   $page     The slug-name of the settings page on which to show the section. Built-in pages include
 *                           'general', 'reading', 'writing', 'discussion', 'media', etc. Create your own using
 *                           add_options_page();
 */
function add_settings_section($id, $title, $callback, $page)
{
    global $wp_settings_sections;
    if ('misc' == $page) {
        _deprecated_argument(__FUNCTION__, '3.0.0', sprintf(__('The "%s" options group has been removed. Use another settings group.'), 'misc'));
        $page = 'general';
    }
    if ('privacy' == $page) {
        _deprecated_argument(__FUNCTION__, '3.5.0', sprintf(__('The "%s" options group has been removed. Use another settings group.'), 'privacy'));
        $page = 'reading';
    }
    $wp_settings_sections[$page][$id] = array('id' => $id, 'title' => $title, 'callback' => $callback);
}

WordPress Version: 4.5

/**
 * Add a new section to a settings page.
 *
 * Part of the Settings API. Use this to define new settings sections for an admin page.
 * Show settings sections in your admin page callback function with do_settings_sections().
 * Add settings fields to your section with add_settings_field()
 *
 * The $callback argument should be the name of a function that echoes out any
 * content you want to show at the top of the settings section before the actual
 * fields. It can output nothing if you want.
 *
 * @since 2.7.0
 *
 * @global $wp_settings_sections Storage array of all settings sections added to admin pages
 *
 * @param string   $id       Slug-name to identify the section. Used in the 'id' attribute of tags.
 * @param string   $title    Formatted title of the section. Shown as the heading for the section.
 * @param callable $callback Function that echos out any content at the top of the section (between heading and fields).
 * @param string   $page     The slug-name of the settings page on which to show the section. Built-in pages include
 *                           'general', 'reading', 'writing', 'discussion', 'media', etc. Create your own using
 *                           add_options_page();
 */
function add_settings_section($id, $title, $callback, $page)
{
    global $wp_settings_sections;
    if ('misc' == $page) {
        _deprecated_argument(__FUNCTION__, '3.0', sprintf(__('The "%s" options group has been removed. Use another settings group.'), 'misc'));
        $page = 'general';
    }
    if ('privacy' == $page) {
        _deprecated_argument(__FUNCTION__, '3.5', sprintf(__('The "%s" options group has been removed. Use another settings group.'), 'privacy'));
        $page = 'reading';
    }
    $wp_settings_sections[$page][$id] = array('id' => $id, 'title' => $title, 'callback' => $callback);
}

WordPress Version: 4.3

/**
 * Add a new section to a settings page.
 *
 * Part of the Settings API. Use this to define new settings sections for an admin page.
 * Show settings sections in your admin page callback function with do_settings_sections().
 * Add settings fields to your section with add_settings_field()
 *
 * The $callback argument should be the name of a function that echoes out any
 * content you want to show at the top of the settings section before the actual
 * fields. It can output nothing if you want.
 *
 * @since 2.7.0
 *
 * @global $wp_settings_sections Storage array of all settings sections added to admin pages
 *
 * @param string $id       Slug-name to identify the section. Used in the 'id' attribute of tags.
 * @param string $title    Formatted title of the section. Shown as the heading for the section.
 * @param string $callback Function that echos out any content at the top of the section (between heading and fields).
 * @param string $page     The slug-name of the settings page on which to show the section. Built-in pages include 'general', 'reading', 'writing', 'discussion', 'media', etc. Create your own using add_options_page();
 */
function add_settings_section($id, $title, $callback, $page)
{
    global $wp_settings_sections;
    if ('misc' == $page) {
        _deprecated_argument(__FUNCTION__, '3.0', sprintf(__('The "%s" options group has been removed. Use another settings group.'), 'misc'));
        $page = 'general';
    }
    if ('privacy' == $page) {
        _deprecated_argument(__FUNCTION__, '3.5', sprintf(__('The "%s" options group has been removed. Use another settings group.'), 'privacy'));
        $page = 'reading';
    }
    $wp_settings_sections[$page][$id] = array('id' => $id, 'title' => $title, 'callback' => $callback);
}

WordPress Version: 3.7

/**
 * Add a new section to a settings page.
 *
 * Part of the Settings API. Use this to define new settings sections for an admin page.
 * Show settings sections in your admin page callback function with do_settings_sections().
 * Add settings fields to your section with add_settings_field()
 *
 * The $callback argument should be the name of a function that echoes out any
 * content you want to show at the top of the settings section before the actual
 * fields. It can output nothing if you want.
 *
 * @since 2.7.0
 *
 * @global $wp_settings_sections Storage array of all settings sections added to admin pages
 *
 * @param string $id Slug-name to identify the section. Used in the 'id' attribute of tags.
 * @param string $title Formatted title of the section. Shown as the heading for the section.
 * @param string $callback Function that echos out any content at the top of the section (between heading and fields).
 * @param string $page The slug-name of the settings page on which to show the section. Built-in pages include 'general', 'reading', 'writing', 'discussion', 'media', etc. Create your own using add_options_page();
 */
function add_settings_section($id, $title, $callback, $page)
{
    global $wp_settings_sections;
    if ('misc' == $page) {
        _deprecated_argument(__FUNCTION__, '3.0', sprintf(__('The "%s" options group has been removed. Use another settings group.'), 'misc'));
        $page = 'general';
    }
    if ('privacy' == $page) {
        _deprecated_argument(__FUNCTION__, '3.5', sprintf(__('The "%s" options group has been removed. Use another settings group.'), 'privacy'));
        $page = 'reading';
    }
    $wp_settings_sections[$page][$id] = array('id' => $id, 'title' => $title, 'callback' => $callback);
}