do_settings_fields()
Print out the settings fields for a particular settings section
Part of the Settings API. Use this in a settings page to output a specific section. Should normally be called by do_settings_sections() rather than directly.
Used By: do_settings_sections()
No Hooks.
Return
null
. Nothing (null).
Usage
do_settings_fields( $page, $section );
- $page(string) (required)
- Slug title of the admin page whose settings fields you want to show.
- $section(string) (required)
- Slug title of the settings section whose fields you want to show.
Examples
#1 Output the registered fields
Suppose we registered new options, added a section and fields to that section. Now, we need to display these fields on the plugin settings page 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( 'primer_group' ); ?> <?php do_settings_fields( 'primer_page' ); ?> <?php submit_button(); ?> </form> </div>
For more info see API settings.
Notes
- Global. Array. $wp_settings_fields Storage array of settings fields and their pages/sections.
Changelog
Since 2.7.0 | Introduced. |