|
I have a widget with 6 different options. When I use
And the output for
Therefore, in order to use the options, I would have to do |
||||||
|
Answers
|
Widgets can be used multiple times. Your options will be passed to the widget directly and automatically, as part of the $instance variable. You should not be getting the options directly using get_option. The widget() function declaration in a WP_Widget derived class looks like this:
The Similarly, the form() function to display the form for the widget looks like this:
Same deal. Finally, the update() function gets two copies of the instanced data, like so:
The update function should validate the options in Look at the widgets in the core, such as TL;DR: WordPress handles the database stuff for widgets automatically. Don’t call get_option, let the underlying |
||||
|