In this tutorial we will create a simple Flicker widget using the Flicker API and the WordPress widget API. The widget can be used multiple times and it will require your Flicker ID and the number of images to display. If we search for something like this we can find a tons of premade widgets, but nothing can be more fun than making it yourself.

Flicker is the most popular photo service out there. By creating the Flicker widget you will learn how to use the Flicker API and how to create WordPress widgets.
You can download the widget here

  1. Create a folder flicker_widget in your plug-ins dir.
  2. Create a php file and name it flicker_widget.php.

Step 1 – Create the widget extend class.

From WordPress 2.8 we can copy and paste the widget skeleton code.

class flickr_widget extends WP_Widget { function flickr_widget() { parent::WP_Widget(false, $name = 'Flickr Widget'); } function form($instance) { } function update($new_instance, $old_instance) { } function widget($args, $instance) { } } add_action( 'widgets_init', 'fw_load_widgets' ); function fw_load_widgets() { register_widget('flickr_widget'); }Step 2 – Making the form.

Before we can make the widget form we need to figure out the input fields that we will use in this widget.
We will need a text filed for the title, the Flicker id and the number of items to display. Copy and paste the code in the form() function.

$title = esc_attr($instance['title']); $flickr_user_id = esc_attr($instance['flickr_user_id']); $flickr_img_limit= esc_attr($instance['flickr_img_limit']); ?>