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

I am making a theme and it has so many options that need to be updated via jquery's ajax.Having looked at ways of updating wp_options via ajax,i have hypothesised that updating the wp_options table would be the easy way out for me.

Are there risks if update the options that way or is it safer to go the api way?.

share|improve this question
your question doesn't entirely make sense. why do you need to use wpdb versus update option? if you have so many options, why are you not saving them as a single serialized option? – Milo Jul 22 '12 at 16:41
I know that's an option,so i want to see the merits or de-merits of using the method i stated - updating the wp_options directly. – Gandalf Jul 22 '12 at 16:46
up vote 2 down vote accepted

Updating options via pure SQL is wrong.

  1. If you feel you have too many options to use the regular API you probably have too many options at all. A theme should not do the job a plugin can do. In fact, it should do as little as possible and let the user choose a plugin for simple tasks.
    Examples are fields for tracking codes or sharing meta data.

  2. Store your options in one array under a single option name. The API will serialize it for you. Exceptions are options you need on de/activation only like the theme version.

  3. If you use the API plugins can hook into pre_get_option_* and extend or change what you do. Don’t break that, you cannot know what your users need.

share|improve this answer

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.