Title: do_settings_fields
Published: April 25, 2014
Last modified: February 24, 2026

---

# do_settings_fields( string $page, string $section )

## In this article

 * [Description](https://developer.wordpress.org/reference/functions/do_settings_fields/?output_format=md#description)
 * [Parameters](https://developer.wordpress.org/reference/functions/do_settings_fields/?output_format=md#parameters)
 * [Source](https://developer.wordpress.org/reference/functions/do_settings_fields/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/functions/do_settings_fields/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/do_settings_fields/?output_format=md#changelog)
 * [User Contributed Notes](https://developer.wordpress.org/reference/functions/do_settings_fields/?output_format=md#user-contributed-notes)

[ Back to top](https://developer.wordpress.org/reference/functions/do_settings_fields/?output_format=md#wp--skip-link--target)

Prints out the settings fields for a particular settings section.

## 󠀁[Description](https://developer.wordpress.org/reference/functions/do_settings_fields/?output_format=md#description)󠁿

Part of the Settings API. Use this in a settings page to output a specific section.
Should normally be called by [do_settings_sections()](https://developer.wordpress.org/reference/functions/do_settings_sections/)
rather than directly.

## 󠀁[Parameters](https://developer.wordpress.org/reference/functions/do_settings_fields/?output_format=md#parameters)󠁿

 `$page`stringrequired

Slug title of the admin page whose settings fields you want to show.

`$section`stringrequired

Slug title of the settings section whose fields you want to show.

## 󠀁[Source](https://developer.wordpress.org/reference/functions/do_settings_fields/?output_format=md#source)󠁿

    ```php
    function do_settings_fields( $page, $section ) {
    	global $wp_settings_fields;

    	if ( ! isset( $wp_settings_fields[ $page ][ $section ] ) ) {
    		return;
    	}

    	foreach ( (array) $wp_settings_fields[ $page ][ $section ] as $field ) {
    		$class = '';

    		if ( ! empty( $field['args']['class'] ) ) {
    			$class = ' class="' . esc_attr( $field['args']['class'] ) . '"';
    		}

    		echo "<tr{$class}>";

    		if ( ! empty( $field['args']['label_for'] ) ) {
    			echo '<th scope="row"><label for="' . esc_attr( $field['args']['label_for'] ) . '">' . $field['title'] . '</label></th>';
    		} else {
    			echo '<th scope="row">' . $field['title'] . '</th>';
    		}

    		echo '<td>';
    		call_user_func( $field['callback'], $field['args'] );
    		echo '</td>';
    		echo '</tr>';
    	}
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-admin/includes/template.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/6.9.4/src/wp-admin/includes/template.php#L1811)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-admin/includes/template.php#L1811-L1838)

## 󠀁[Related](https://developer.wordpress.org/reference/functions/do_settings_fields/?output_format=md#related)󠁿

| Uses | Description | 
| [esc_attr()](https://developer.wordpress.org/reference/functions/esc_attr/)`wp-includes/formatting.php` |

Escaping for HTML attributes.

  |

| Used by | Description | 
| [do_settings_sections()](https://developer.wordpress.org/reference/functions/do_settings_sections/)`wp-admin/includes/template.php` |

Prints out all settings sections added to a particular settings page.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/do_settings_fields/?output_format=md#changelog)󠁿

| Version | Description | 
| [2.7.0](https://developer.wordpress.org/reference/since/2.7.0/) | Introduced. |

## 󠀁[User Contributed Notes](https://developer.wordpress.org/reference/functions/do_settings_fields/?output_format=md#user-contributed-notes)󠁿

 1.   [Skip to note 2 content](https://developer.wordpress.org/reference/functions/do_settings_fields/?output_format=md#comment-content-3140)
 2.    [Khoi Pro](https://profiles.wordpress.org/khoipro/)  [  7 years ago  ](https://developer.wordpress.org/reference/functions/do_settings_fields/#comment-3140)
 3.  [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fdo_settings_fields%2F%23comment-3140)
     Vote results for this note: 2[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fdo_settings_fields%2F%23comment-3140)
 4.  To load multiple tabs in custom page settings, you will need to use this function.
 5.  For example, if I wish to have these settings pages:
 6.   * /options-general.php?page=stripe-payment – Default page
      * /options-general.php?page=stripe-payment&action=test – Test page
 7.  So you must have two different sections and call it like:
 8.      ```php
         if ($_GET['action'] !== 'test') {
           settings_fields('stripe_payment_settings');
           echo '<table class="form-table">'; // Must to add this wrapper to keep it like WordPress default UI
           do_settings_fields('stripe-payment, 'stripe_payment_settings_section');
           echo '</table>';
         } else {
           settings_fields('stripe_payment_test');
           echo '<table class="form-table">';
           do_settings_fields('stripe-payment, 'stripe_payment_test_section');
           echo '</table>';
         }
         ```
     
 9.   [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fdo_settings_fields%2F%3Freplytocom%3D3140%23feedback-editor-3140)

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fdo_settings_fields%2F)
before being able to contribute a note or feedback.