dynamic_sidebar
Action HookDescription
Calls the render callback of a widget and returns the output.Hook Information
File Location |
wp-includes/widgets.php
View on GitHub
|
Hook Type | Action |
Line Number | 2038 |
Hook Parameters
Type | Name | Description |
---|---|---|
string
|
$widget_id
|
Widget ID. |
string
|
$sidebar_id
|
Sidebar ID. |
Usage Examples
Basic Usage
<?php
// Hook into dynamic_sidebar
add_action('dynamic_sidebar', 'my_custom_function', 10, 2);
function my_custom_function($widget_id, $sidebar_id) {
// Your custom code here
}
Source Code Context
wp-includes/widgets.php:2038
- How this hook is used in WordPress core
<?php
2033 $callback = $wp_registered_widgets[ $widget_id ]['callback'];
2034
2035 ob_start();
2036
2037 /** This filter is documented in wp-includes/widgets.php */
2038 do_action( 'dynamic_sidebar', $wp_registered_widgets[ $widget_id ] );
2039
2040 if ( is_callable( $callback ) ) {
2041 call_user_func_array( $callback, $params );
2042 }
2043
PHP Documentation
<?php
/**
* Calls the render callback of a widget and returns the output.
*
* @since 5.8.0
*
* @global array $wp_registered_widgets The registered widgets.
* @global array $wp_registered_sidebars The registered sidebars.
*
* @param string $widget_id Widget ID.
* @param string $sidebar_id Sidebar ID.
* @return string
*/
Quick Info
- Hook Type: Action
- Parameters: 2
- File: wp-includes/widgets.php
Related Hooks
Related hooks will be displayed here in future updates.