Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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';
}

Outputs:

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

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

share|improve this question

1 Answer 1

up vote 2 down vote accepted

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.

share|improve this answer
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. –  Chip Bennett Feb 8 '12 at 20:52
    
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 :) –  Wordpressor Feb 8 '12 at 21:06
1  
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. :) –  Chip Bennett Feb 8 '12 at 21:12
1  
It's really solid for just extending the core capabilities and core feel of wordpress. –  m0r7if3r Feb 8 '12 at 21:12
1  
@Wordpressor There is version of the tutorial in one page. –  toscho Feb 8 '12 at 22:02

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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