• When I call update_option() in my widget, nothing ever appears in the database wp_options table for my widget. So when I go back to the widget page, all the settings have disappeared. Is there any way I can find out why it won’t save to the database?

Viewing 1 replies (of 1 total)
  • first off are you seeing any error statements in your server logs? Also, are you sure that that part of the code is running? If it’s in a conditional you might actually not be satisfying the argument to have the update_option happen. One way to check is place an echo statement or something in the same area and have it say “I’m in the right place” or whatever so that you are sure it’s actually following the path you expect it to. Lastly, make sure that the variable(s) you want updated actually have values, in many cases a programming issue can be missed that causes the value to not exist therefore having nothing to write to the database.

    I don’t believe you need to do this, but if this code is in a function you might want to global $wpdb in it just in case for some reason it’s not connecting to your database.

Viewing 1 replies (of 1 total)
  • The topic ‘update_option doesn’t save options to database’ is closed to new replies.