do_settings_sections()
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()
Uses: do_settings_fields()
No Hooks.
Return
null
. Nothing (null).
Usage
do_settings_sections( $page );
- $page(string) (required)
- The slug name of the page whose settings sections you want to output.
Examples
#1 Displaying settings sections on the settings page
Suppose we registered new options, added a block and fields to this block. Now, we need to display these fields on the settings page of the plugin in the admin panel, then use this function:
<div class="wrap"> <?php screen_icon(); ?> <h2>Primer plugin settings</h2> <form action="options.php" method="POST"> <?php settings_fields( 'option_id' ); ?> <?php do_settings_sections( 'primer_page' ); ?> <?php submit_button(); ?> </form> </div>
See the Settings API for a full example of how to use it.
Notes
- Global. Array. $wp_settings_sections Storage array of all settings sections added to admin pages.
- Global. Array. $wp_settings_fields Storage array of settings fields and info about their pages/sections.
Changelog
Since 2.7.0 | Introduced. |