WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

And which one should I use?

What's the difference between Options API and Setings API?

I have a theme with over 100 admin options, how should I register & store them? At this moment I'm using Options API but I'm not too happy with it, every single option is being registered separately so they create a lot of database queries.

I see three ways of storing WordPress options/settings at the moment:

1. Options API - the old (the worst?) way.

(I'm using this one already)

<form method="post" action="options.php">
<?php wp_nonce_field('update-options'); ?>        

// all the inputs

<input type="hidden" name="action" value="update" />
<input type="hidden" name="page_options" value="option1,option2,option3,..." />
<p class="submit">
<input type="submit" value="<?php _e('Save Changes') ?>" />

And then in the front end:

echo get_option('option1'); 

Looks ugly and I don't think that's the right way of storing big number of options (I'd love to group them somehow).

2. Options API - 1 option as a big array.

I'm not sure here how to update this array using html forms, anyone? I believe it should go like:

$opt['option1'] = foo
$opt['option2'] = foo
$opt['option3'] = bar


And then in front end:

$settings = get_option('theme_settings');
echo $settings['option1']; 
echo $settings['option2']; 
echo $settings['option3']; 

I've heard it really decreases number of queries and I have them all as one option. I'd love to use this one but as I mentioned above I'm not sure how to update this array of options within Wordpress admin form. I guess: <input type="hidden" name="theme_settings" value="option1,option2,option3,..." /> will overwrite the array instead of adding new elements?

3. Settings API - the new way.

Requires a lot of additional code:

function register_theme_settings() {
    //register our settings   
    register_setting( 'theme-settings', 'option1' );     
    register_setting( 'theme-settings', 'option2' );     
    register_setting( 'theme-settings', 'option3' );     
    register_setting( 'theme-settings', 'option4' );     
    register_setting( 'theme-settings', 'option5' );     
    // imagine this for 100 and more options    

And I'm not sure what's the difference between this and the method with one option as an array?

tl;dr So, how should I project my theme settings storage so it will be working fast and store all the options/settings in one place so I will be able to, for example, echo/dump them all with one simple function (yes, I want to do that badly but I have no idea how to do that with this Settings API). The second method looks the best so far.

share|improve this question
up vote 7 down vote accepted

The Options API is primarily a database API, allowing you to get and store values in the options table of the database easily.

The Settings API is an interface API. It allows you to build settings screens in a manner that will adapt with future changes to the WordPress interface, as well as to handle security (nonces and whitelisting and validation and such) automatically and more easily than rolling-your-own-code.

More on Settings API: http://ottopress.com/2009/wordpress-settings-api-tutorial/

share|improve this answer
+1. The Settings API is the correct approach, and will handle your 100 Theme options without batting an eye. Some fool wrote a really long-winded tutorial for incorporating the Settings API in WordPress Themes. – Chip Bennett Feb 2 '12 at 3:23
Otto, @Chip Bennett thank you guys. I have one more additional question - according to documentation I should create multiple settings groups for each admin page, will it affect performance / number of queries somehow? Is there anything wrong with keeping all the options within one group (let's say 'theme-settings') as I explained in my too long to read question? :) – Wordpressor Feb 2 '12 at 12:34
I would recommend using only one options group. If you need UI organization, use settings sections, and or settings page tabs. – Chip Bennett Feb 2 '12 at 14:30
@Chip Bennett, alright, thanks a lot :) Great tutorial btw. – Wordpressor Feb 2 '12 at 15:43

Your Answer


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.