I have been building a tabbed option page based on some tutorials I found, using the settings API. Here is the code http://pastebin.com/bbSnhFP5 . It's all actually working fine for me but it's not ideal and I'm sure there's a better way around it.

The problem is that when I used this tutorial as a base and adapted it to use add_settings_section() and add_settings_field() calls, I ended up with code which used register_setting() (as opposed to perhaps add_theme_page()) to make the distinction between the tabs ( this is the way the tutorial did it ). This meant that I had to use do_settings_fields() to print the fields instead of do_settings_sections() because do_settings_sections() prints out the entire page of options (as defined by add_theme_page()) on every tab.

The end result of this is that while I need to have the add_settings_section() calls ( because I'm using do_settings_section()) and therefore I need to have callbacks for them, the callbacks cant actually be made to do anything because as far as I know the only way to print out these callbacks is to use do_settings_sections() which I cant use, so it seems like I'm missing something.

As a sort of hack I have used a switch statement to allow me to put some text at the start of each page but I feel there must be a better way of doing this and some way of allowing multiple sections per tab.

Can anyone add anything?

  • Please use code mark-up for code and not bold.
    – kaiser
    Mar 7, 2012 at 11:43
  • 2
    Thanks Kaiser, I just thought it would be easier to read with those functions highlighted somehow - I didn't think putting them into blocks would work as they were part of the flow of the paragraph but I've removed the bold now. Mar 7, 2012 at 15:18

1 Answer 1


You only need one register_setting() call. The rest can be handled internally. I wrote a Settings API tutorial that explains how to do so.

Without delving too deeply into the code from the tutorial you linked, just based on the screenshot it appears that the Digital Raindrops code bypasses the standard, WordPress core admin UI to do something different with the sections within each page tab.

  • Thanks. I'm looking at your tutorial now. What do you mean by internally though? Do you mean via some part of the settings API, or via my own code. I don't see yet how having more than one register_setting() is the problem. Where I'm stumped is that if the add_settings section() calls can only be printed out using do_settings_sections(), then seeing as that function prints out all the sections of the entire options page, I seem to need a separate options page for each tab, which I cant have as I only have one actual options page (divided into tabs). Clearly my understanding is wrong somewhere? Mar 7, 2012 at 15:38
  • All you have to do is to define sections by tab. I've updated my own Oenology code since writing that tutorial. You can see here how I segregate the do_settings_sections() calls by tab. Mar 7, 2012 at 15:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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