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.

I'm looking for a function, NOT A PLUGIN, that allow me to remove the Inactive Widgets... there was a topic before Script to remove all inactive widgets? with an answer, however it's not working for me.

Any other solutions?

Regards.!

enter image description here

share|improve this question

1 Answer 1

up vote 3 down vote accepted
function andrew_unregister_widgets() {
    unregister_widget( 'WP_Widget_Archives' );
    unregister_widget( 'WP_Widget_Calendar' );
    unregister_widget( 'WP_Widget_Categories' );
    unregister_widget( 'WP_Widget_Links' );
    unregister_widget( 'WP_Widget_Meta' );
    unregister_widget( 'WP_Widget_Pages' );
    unregister_widget( 'WP_Widget_Recent_Comments' );
    unregister_widget( 'WP_Widget_Recent_Posts' );
    unregister_widget( 'WP_Widget_RSS' );
    unregister_widget( 'WP_Widget_Search' );
    unregister_widget( 'WP_Widget_Tag_Cloud' );
    unregister_widget( 'WP_Widget_Text' );
}
add_action( 'widgets_init', 'andrew_unregister_widgets()' );

This unregisters all in-built wordpress widgets. Which ones of those are already active you'd have to manually check and remove from the function before adding it to your functions.php file.

EDIT: Removing inactive widgets when the admin area loads:

function andrew_remove_inactive_widgets() {
    $widgets = get_option( 'sidebars_widgets' );
    $widgets['wp_inactive_widgets'] = array();
    update_option( 'sidebars_widgets', $widgets );
}
add_action( 'admin_init', 'andrew_remove_inactive_widgets' );
share|improve this answer
    
yeah I already have this one, however I'm looking to remove those which are below, the inactive widgets sections, I just added a pic of the exactly section, any ideas? –  andresmijares25 Nov 20 '11 at 20:31
    
@andrewkthx Mkay. Updated the answer. Clears the section in question on my 3.2.1 dev install. –  Johannes Pille Nov 20 '11 at 20:53
    
that's weird, that solution is similar to the post I mentioned before, however it doesn't work for me, I tried on 3 different environments w/o success –  andresmijares25 Nov 20 '11 at 21:19

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.