WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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 have read a lot of turorials an even the codex widget API, but can't solve my doubts: What are the really difference writing WorPress 3.x widget plugins? if there exists.

this doubt came when trying to create plugin containing an widget I have actived WP_DEBUG and saw the notice that register_sidebar_widget() is deprecated and I should use wp_register_sidebar_widget() instead.

So I have changed and now I get:

Notice: Uninitialized string offset: 0 in /.../wp-content/plugins/raz/index.php on line 54

Notice: Uninitialized string offset: 0 in /.../wp-content/plugins/raz/index.php on line 55

Notice: Uninitialized string offset: 0 in /.../wp-content/plugins/raz/index.php on line 55

Here is the code:


// widget to show an iframe containing Brazilian CPTEC weather forecast
function previsao_tempo_cptec_widget_display($args) {

  // print some HTML for the widget to display here
  print $args['before_widget'];
  print $args['before_title'] . "Previsão IN TITLE do Tempo - CPTEC" . $args['after_title'];

  //  print "content of the widget";
  print '<center><!-- Widget Previs&atilde;o de Tempo CPTEC/INPE --><iframe allowtransparency="true" marginwidth="0" marginheight="0" hspace="0" vspace="0" frameborder="0" scrolling="no" src="http://www.cptec.inpe.br/widget/widget.php?p=4599&w=h&c=909090&f=ffffff" height="200px" width="215px"></iframe><noscript>Previs&atilde;o de <a href="http://www.cptec.inpe.br/cidades/tempo/4599">Santa Maria/RS</a> oferecido por <a href="http://www.cptec.inpe.br">CPTEC/INPE</a></noscript><!-- Widget Previs&atilde;o de Tempo CPTEC/INPE --></center>';
  print $args['after_widget'];   


// Activate the sidebar
    'Previsão de Tempo - CPTEC',     
        'description' => "Este  widget mostra a previsão de Tempo  pelo CPTEC - INPE/BR"      
    'before_widget' => '<li>',
    'after_widget'  => '</li>',
    'before_title'  => '<h2 class="widgettitle">',
    'after_title'   => '</h2>'

// Loads the widget

Other doubt, why this widget is always displayed in the top of my website and in the sidebar widgets also?

Thanks for any incoming handy answer.

share|improve this question

migrated from stackoverflow.com Jul 2 '11 at 22:38

This question came from our site for professional and enthusiast programmers.

up vote 3 down vote accepted

As per your other question rather than trying to use older API to implement widgets it is better to use newer and current approach as per Widgets API in Codex.

The difference is that newer code is more reliable and more functional (allows to easily have more complex features, such as multiple instances of the widget).

So issues with your code example are probably not worth fixing, better to just move to using currently suggested way.

share|improve this answer
Thanks Rarst,I have passe all last night reading and rewriting the code using current approach. Now it works perfectly. Again, thanks for your words and suggestion. – Hans Zimermann Jul 3 '11 at 21:43

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.