# Unregistering Widgets

Elementor Core Intermediate

Developers can remove Elementor widgets from the list of registered widgets. This is done by hooking to the widget manager and unregistering specific widgets by passing the widget name.

# Unregistering Existing Widgets

Developers should use the following code to unregister existing widgets:

/**
 * Unregister Elementor widgets.
 *
 * @param \Elementor\Widgets_Manager $widgets_manager Elementor widgets manager.
 * @return void
 */
function unregister_widgets( $widgets_manager ) {

	$widgets_manager->unregister( 'widget-1' );
	$widgets_manager->unregister( 'widget-2' );

}
add_action( 'elementor/widgets/register', 'unregister_widgets' );
1
2
3
4
5
6
7
8
9
10
11
12
13

This code hooks to the elementor/widgets/register action hook which holds the widget manager. The manager then unregisters widgets by passing the widget name.

# Remove Unused Widgets

To remove multiple widgets that are not used in your site, you can run a "foreach" loop with a list of widget names.

/**
 * Unregister multiple unused widgets.
 *
 * @param \Elementor\Widgets_Manager $widgets_manager Elementor widgets manager.
 * @return void
 */
function remove_unused_widgets( $widgets_manager ) {

	$widgets_to_unregister = [
		// 'common',
		// 'inner-section',
		// 'heading',
		// 'image',
		// 'text-editor',
		// 'video',
		// 'button',
		// 'divider',
		// 'spacer',
		// 'image-box',
		// 'google_maps',
		// 'icon',
		// 'icon-box',
		// 'star-rating',
		// 'image-carousel',
		// 'image-gallery',
		// 'icon-list',
		// 'counter',
		// 'progress',
		// 'testimonial',
		// 'tabs',
		// 'accordion',
		// 'toggle',
		// 'social-icons',
		// 'alert',
		// 'audio',
		// 'shortcode',
		// 'html',
		// 'menu-anchor',
		// 'sidebar',
		// 'read-more',
	];

	foreach ( $widgets_to_unregister as $widget ) {
		$widgets_manager->unregister( $widget );
	}

}
add_action( 'elementor/widgets/register', 'remove_unused_widgets' );
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48

Developers can use this logic and build a UI around it to create a visual widgets manager.