Posts Tagged Widgets

How to use widget multiple times

In WordPress 2.8, there’s a new widget API. The new widgets API is a class that abstracts away much of the complexity involved in writing a widget, especially multi-widgets.

Basically, you extend WP_Widget with your own class that provides a constructor and three methods — widget(), form(), and update().

  • widget() – outputs the actual content of the widget.
  • update() – processes options to be saved.
  • form() – outputs the options form.

* The WP_Widget source can be viewed here (read the phpdoc for moreinfo on usage): http://core.trac.wordpress.org/browser/trunk/wp-includes/widgets.php
* You can see examples of how to use it here: http://core.trac.wordpress.org/browser/trunk/wp-includes/default-widgets.php

Here’s an execelent example of the widget.

, , , , , , , , ,

No Comments