I have a theme that I'm developing from an HTML template I have. I'm also designing an options page along with a plethora of plugins built-into the theme itself. I've chosen a tabbed interface and I'm trying to learn how to use WordPress' Settings API.

I'm using a class structure for the theme's functions. The following is the declaration of registering settings and whatnot.

public function __admin_init()
    register_setting( 'cncfps_twitter', 'cncfps_twitter_options', array( &$this, 'wp_cncfps_twitter' ) );
    add_settings_section( 'cncfps_twitter', 'Twitter', array( &$this, 'wp_cncfps_twitter' ), 'cncfps' );
    add_settings_field( 'cncfps_twitter_consumer_key', 'Consumer Key', array( &$this, 'twitter_consumer_key' ), 'cncfps', 'cncfps_twitter' );
    add_settings_field( 'cncfps_twitter_consumer_secret', 'Consumer Secret', array( &$this, 'twitter_consumer_secret' ), 'cncfps', 'cncfps_twitter' );
    add_settings_field( 'cncfps_twitter_apikey', 'API Key', array( &$this, 'twitter_apikey' ), 'cncfps', 'cncfps_twitter' );

public function wp_cncfps_twitter()
    // TODO: wut. ?!?!
    echo "what is this?";

public function twitter_consumer_key()
    echo "Hello";

public function twitter_consumer_secret()
    echo "World";

When I want to display the fields as shown here, I don't see a thing. The following is how I attempt to display them. I did follow a few tutorials but it's just not clicking in my brain for some reason.


enter image description here


The do_settings_section() function call needs to correspond to the $optiongroup argument you pass to register_setting(). To see how all of the myriad functions fit together, see page 10 of my tutorial.

It does get fairly confusing trying to follow how the various functions string together.


You do appear to be using the option group properly. Can you clarify what is/is not "clicking" for you? You mention in the title that you want to use a tabbed interface, but the question text itself doesn't really indicate where exactly you're running into difficulty.

  • The screenshot should be quite clear. Nothing shows up and the only thing that I can believe is that it doesn't support class-structure. :/ – Zack May 31 '11 at 20:45
  • What screenshot? – Chip Bennett May 31 '11 at 21:11
  • The one in my post? O.o – Zack May 31 '11 at 21:40
  • That's really strange; no screenshot appeared for me in your post, until this morning... – Chip Bennett Jun 1 '11 at 12:25
  • The difficulty I'm running into is the that nothing shows when I call the do_settings_section/settings_fields functions :\ – Zack Jun 3 '11 at 16:21

I also had a blank page when I tried implementing the suggested code. For some reason, my site didn't like all the double-quotes in this section (from page 3 of Chip's tutorial):

if ( $tab == $current ) :
    $links[] = "<a class="nav-tab nav-tab-active" href="?page=oenology-    settings&tab=$tab">$name</a>";
else :
    $links[] = "<a class="nav-tab" href="?page=oenology-settings&tab=$tab">$name</a>";

I had to change it and make use of single quotes:

if ( $tab == $current ) :
    $links[] = '<a class="nav-tab nav-tab-active" href="?page=oenology-settings&tab=' . $tab . '">' . $name . '</a>';
else :
    $links[] = '<a class="nav-tab" href="?page=oenology-settings&tab=' . $tab . '">' . $name . '</a>';

That seemed to fix it for me. I'm not sure if that's the same problem you're facing though.

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.