Fires after all default WordPress widgets have been registered.
Source
do_action( 'widgets_init' );
Changelog
Version | Description |
---|---|
2.2.0 | Introduced. |
Fires after all default WordPress widgets have been registered.
do_action( 'widgets_init' );
Version | Description |
---|---|
2.2.0 | Introduced. |
You must log in before being able to contribute a note or feedback.
You should note that the
widgets_init
hook is fired as part of theinit
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.add_action( 'init', 'wpdocs_my_init', 0 ); function wpdocs_my_init() { $terms = get_terms( 'ts_product_brand', array( 'hide_empty' => true ) ); if ( ! is_array( $terms ) || count( $terms ) < 2 ) { remove_action( 'widgets_init', 'ts_product_filter_by_brand_load_widget' ); } }
For example, used with registering sidebars: