do_action( ‘widgets_init’ )

Fires after all default WordPress widgets have been registered.

Source

do_action( 'widgets_init' );

Changelog

VersionDescription
2.2.0Introduced.

User Contributed Notes

  1. Skip to note 3 content

    You should note that the widgets_init hook is fired as part of the init hook – with a priority of 1.

    This means that it will fire before any code you may add to the init hook with a default priority.

  2. Skip to note 4 content

    For example, used with registering sidebars:

    function mytheme_widgets_init() {
    	register_sidebar( array(
    		'name'          => __( 'Single Post Widgets', 'textdomain' ),
    		'id'            => 'mytheme-single-post-widgets',
    		'description'   => __( 'Widgets in this area will be shown under your single posts, before comments.', 'textdomain' ),
    		'before_widget'	=> '',
    		'after_widget'	=> '',
    		'before_title'	=> '',
    		'after_title'	=> '',
        ) );
    }
    add_action( 'widgets_init', 'mytheme_widgets_init' );

You must log in before being able to contribute a note or feedback.