1

If my theme has a lot of options is it better to store all options in one database entry, or to use a databse entry for each group of options? IE would I name all options like this themeSlug[optionType_specificOption] or like this: themeSlug_optionType[specificOption]?In the latter example if I need the settings for my post slider I would do $sliderOptions = get_option('themeSlug_slider');.

I guess my question is do I see any performance benefit to making several smaller queries vs one large query for my options? Are their any other advantages/disadvantages to grouping my options into different entries?

2

All options with autoload = yes (default) are fetched very early in one query. So the number of options does affect performance only marginally.

Split options if you don’t need everything on every page load. With …

add_option( 'option_name', 'option_value', '', 'no' );

… you can set options that aren’t loaded before you actually call get_option().

  • I didn't know you can do that. Can I do that when I am creating options via the theme customizer? – JPollock Jul 26 '13 at 4:14
  • 1
    You have to call add_option() before you start the customizer code. – fuxia Jul 26 '13 at 4:17

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.