I'm using Settings API and wondering if there's any way of editing default output of add_settings_field() function?

add_settings_field('the_field', 'bar', 'foo', 'page', 'section');      

function foo() {
    echo 'foo';


<table class="form-table">
  <tr valign="top">
    <th scope="row">bar</th>

How to get rid of these table tags and replace them with something else?

2 Answers 2


If you look at do_settings_fields() (line 1125, /wp-admin/includes/template.php), you can see that the table information is hardcoded into the the settings API. If you wish to not use the table, you will need to develop your own settings functions.

  • 1
    Indeed. Using do_settings_fields() is basically using the API to determine the output markup. Doing so has its advantages (UI consistency, forward-compatibility), but if you must output custom markup, then you'll have to omit the do_settings_fields() call, and add your own, custom markup. Feb 8, 2012 at 20:52
  • 1
    Thanks! :) I knew about template.php, but was hoping it's still changeable. This whole Settings API looks amazing at first but after some digging it's not so easy to customize and use at all :) And all the tutorials make me just more confused :) Feb 8, 2012 at 21:06
  • 2
    As an author of one such tutorial, I'd love to know where you find it confusing, so that I can improve it. The intent is to eliminate confusion, rather than to create more. :) Feb 8, 2012 at 21:12
  • 1
    It's really solid for just extending the core capabilities and core feel of wordpress.
    – mor7ifer
    Feb 8, 2012 at 21:12
  • 1
    @Wordpressor There is version of the tutorial in one page.
    – fuxia
    Feb 8, 2012 at 22:02

My custom function for this:

 * Prints out one specified field from settings section.
 * Based on:
 * @see do_settings_sections
 * @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
 * @param string $page                  The slug name of the page whose settings sections you want to output
 * @param string $field_id              Field ID for output
public static function do_settings_section_field($page, $field_id) {
    global $wp_settings_sections, $wp_settings_fields;

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

    foreach ( (array) $wp_settings_sections[$page] as $section ) {

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

        if ( ! isset( $wp_settings_fields[$page][$section['id']] ) )

        foreach ( (array) $wp_settings_fields[$page][$section['id']] as $field ) {
            if ( $field['id'] !== $field_id )

            call_user_func($field['callback'], $field['args']);

You can use this function instead of do_settings_sections(), with the same first arguments and field ID for render as second argument.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.