0

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

3
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' );
  • 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? – andresmijares 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 – andresmijares Nov 20 '11 at 21:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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