WordPress at a glance

do_settings_sections() WP 1.0

Prints out all settings sections added to a particular settings page

Part of the Settings API. Use this in a settings page callback function to output all the sections and fields that were added to that $page with add_settings_section() and add_settings_field()

  • Global. $wp_settings_sections. Storage array of all settings sections added to admin pages
  • Global. $wp_settings_fields. Storage array of settings fields and info about their pages/sections

No Hooks.


Nothing (null).


do_settings_sections( $page );
$page(string) (required)
The slug name of the page whose settings sections you want to output

Code of do settings sections: wp-admin/includes/template.php VER 5.0.3

function do_settings_sections( $page ) {
	global $wp_settings_sections, $wp_settings_fields;

	if ( ! isset( $wp_settings_sections[$page] ) )

	foreach ( (array) $wp_settings_sections[$page] as $section ) {
		if ( $section['title'] )
			echo "<h2>{$section['title']}</h2>\n";

		if ( $section['callback'] )
			call_user_func( $section['callback'], $section );

		if ( ! isset( $wp_settings_fields ) || !isset( $wp_settings_fields[$page] ) || !isset( $wp_settings_fields[$page][$section['id']] ) )
		echo '<table class="form-table">';
		do_settings_fields( $page, $section['id'] );
		echo '</table>';

Related Functions

From category: Settings API

No comments
    Hello, !     Log In . Register