10

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.

1 Answer 1

11

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.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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