WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I created this widget using a simple example on WordPress Codex:


function widget_container_latest_posts() {
                             global $wpdb;
                  global $post;
                                get_template_part( '/includes/containers/container-latest-posts' );

    'Container Latest Posts',
    'description' => 'Container Latest Posts - Adds recent posts.'

It works fine, but I want this widget to be used multiple times not only one time after I drag it on a sidebar widgets place, and so I can add it on all the other sidebars for example. Thank

share|improve this question
up vote 3 down vote accepted

You need to implement your Widget using the Widgets API, so that WordPress knows how to make multiple instances of the Widget.

Your Widget declaration should take the following format:

class My_Widget extends WP_Widget {
    function My_Widget() {
        // widget actual processes

    function form($instance) {
        // outputs the options form on admin

    function update($new_instance, $old_instance) {
        // processes widget options to be saved

    function widget($args, $instance) {
        // outputs the content of the widget

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.