Action hook 'widgets_init'

in WP Core File wp-includes/widgets.php at line 1870

View Source

widgets_init

Action Hook
Description
Fires after all default WordPress widgets have been registered.

Hook Information

File Location wp-includes/widgets.php View on GitHub
Hook Type Action
Line Number 1870

Hook Parameters

This hook doesn't accept any parameters.

Usage Examples

Basic Usage
<?php
// Hook into widgets_init
add_action('widgets_init', 'my_custom_function');

function my_custom_function() {
    // Your custom code here
}

Source Code Context

wp-includes/widgets.php:1870 - How this hook is used in WordPress core
<?php
1865  	/**
1866  	 * Fires after all default WordPress widgets have been registered.
1867  	 *
1868  	 * @since 2.2.0
1869  	 */
1870  	do_action( 'widgets_init' );
1871  }
1872  
1873  /**
1874   * Enables the widgets block editor. This is hooked into 'after_setup_theme' so
1875   * that the block editor is enabled by default but can be disabled by themes.

PHP Documentation

<?php
/**
	 * Fires after all default WordPress widgets have been registered.
	 *
	 * @since 2.2.0
	 */
Quick Info
  • Hook Type: Action
  • Parameters: 0
  • File: wp-includes/widgets.php
Related Hooks

Related hooks will be displayed here in future updates.