开发者

How to save WP widget instances to options

I'm a little confused about this, even though I have read all of the API and searched for hours.

When I activate my plugin I add some values to the options database, e.g.

add_option('code','24');

How do I update that value or use it in the widget? I only see "instances" now, like the example on this page:

http://wpcoderz.com/creating-a-multi-instance-widget-with-wordpress-2-开发者_开发问答8/


You can get an option using get_option and update it using update_option. But you should use instances instead of options for widget settings (like title) because that's the purpose of instances. You don't have to care about storing instance value - WP does it for you. If you don't understand instances well, look at codex.wordpress.org/Widgets_API.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜