0

I wonder if possible to disable a widget that belongs to a plugin that is currently active w/o touching the plugin code.

For sample, I normally use a code like this to disable wordpress widgets,

 unregister_widget('WP_Widget_Text');

Now, I want to also deactivate let's say for sample the widget called "The other Widget"

is that possible?

Thanks in advanced.

2
  • you can't unregister it in your theme's function.php using a higher priority than the plugin is using?
    – Brooke.
    Dec 28, 2011 at 8:52
  • that was my first thought, however didn't work for me Dec 28, 2011 at 8:56

1 Answer 1

2

You must use widgets_init hook with a high priority for example this will remove the default WP Widgets

function unregister_default_wp_widgets() {
    unregister_widget('WP_Widget_Pages');
    unregister_widget('WP_Widget_Calendar');
    unregister_widget('WP_Widget_Archives');
    unregister_widget('WP_Widget_Links');
    unregister_widget('WP_Widget_Meta');
    unregister_widget('WP_Widget_Search');
    unregister_widget('WP_Widget_Text');
    unregister_widget('WP_Widget_Categories');
    unregister_widget('WP_Widget_Recent_Posts');
    unregister_widget('WP_Widget_Recent_Comments');
    unregister_widget('WP_Widget_RSS');
    unregister_widget('WP_Widget_Tag_Cloud');
}
add_action('widgets_init', 'unregister_default_wp_widgets', 1);
1
  • Hi, thanks for your answer, but as I showed in my example, I've already tried with it, however I'm looking to disable other plugins which are from other plugins, like nextgen gallery, or meteor slide, or whatever. Any guessing? Dec 28, 2011 at 21:05

Your Answer

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

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