dynamic_sidebar WordPress Action Hook

The dynamic_sidebar hook is one of the most versatile hooks in WordPress. It allows you to insert a custom sidebar anywhere on your site. This hook is especially useful for customizing the sidebars of your theme. With this hook, you can specify the name of the sidebar you want to use, as well as the id and class attributes. You can also choose to display the sidebar before or after the content. This hook gives you a lot of flexibility in how you want to display your sidebars. You can use it to create a unique sidebar for each page of your site, or you can use it to display a different sidebar on different devices. If you're looking for a way to customize the sidebars of your WordPress site, the dynamic_sidebar hook is a great option.

do_action( 'dynamic_sidebar', array $widget ) #

Fires before a widget’s display callback is called.


Description

Note: The action fires on both the front end and back end, including for widgets in the Inactive Widgets sidebar on the Widgets screen.

The action is not fired for empty sidebars.


Top ↑

Parameters

$widget

(array)An associative array of widget arguments.

  • 'name'
    (string) Name of the widget.
  • 'id'
    (string) Widget ID.
  • 'callback'
    (callable) When the hook is fired on the front end, $callback is an array containing the widget object. Fired on the back end, $callback is 'wp_widget_control', see $_callback.
  • 'params'
    (array) An associative array of multi-widget arguments.
  • 'classname'
    (string) CSS class applied to the widget container.
  • 'description'
    (string) The widget description.
  • '_callback'
    (array) When the hook is fired on the back end, $_callback is populated with an array containing the widget object, see $callback.


Top ↑

Source

File: wp-includes/widgets.php

View on Trac



Top ↑

Changelog

Changelog
VersionDescription
3.0.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.