Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

What's the difference between them and when should we use each one ?

I'm using wp_register_sidebar_widget right now and it's working fine but I've seen a lot of tutorials online on how to create a widget using register_widget and a class, most of my widgets doesn't need options so should I stick to wp_register_sidebar_widget or should I use register_widget even if I don't have a form ?

thanks in advance.

share|improve this question
add comment

1 Answer

up vote 5 down vote accepted

wp_register_sidebar_widget() is part of the old widgets API. Sidebar widgets used to be built procedurally ... in a non-reusable fashion (i.e. you could only ever have one of each).

register_widget() was introduced with the new Widgets API and takes an object/class as an input rather than actual widget parameters. WordPress can instantiate as many copies of this widget as you need, allowing you to have several instances of the exact same widget.

You should be using individual widget classes and register_widget() even if your widget doesn't have an input form.

share|improve this answer
    
thank you very much :) –  Peter Apr 3 '12 at 5:17
add comment

Your Answer

 
discard

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.