# Registering Widgets
Elementor Core IntermediateWhen you create new Elementor widgets, you must register them. This is done by hooking to the registration hook in the widgets manager and passing a new widget instance.
# Registering New Widgets
Developers should use the following code to register new widgets:
/**
* Register new Elementor widgets.
*
* @param \Elementor\Widgets_Manager $widgets_manager Elementor widgets manager.
* @return void
*/
function register_new_widgets( $widgets_manager ) {
require_once( __DIR__ . '/widgets/widget-1.php' );
require_once( __DIR__ . '/widgets/widget-2.php' );
$widgets_manager->register( new \Elementor_Widget_1() );
$widgets_manager->register( new \Elementor_Widget_2() );
}
add_action( 'elementor/widgets/register', 'register_new_widgets' );
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
This code hooks to the elementor/widgets/register
action hook which holds the widgets manager. The manager then registers new widgets by passing the widget instance.