Output an arbitrary widget as a template tag
Signature
the_widget( $widget, $instance = array(), $args = array() )
- widget
- (string) the widget's PHP class name (see default-widgets.php)
- instance
- (array) the widget's instance settings
Default:array() - args
- (array) the widget's sidebar args
Default:array()
Return
(void)
Source
function the_widget($widget, $instance = array(), $args = array()) {
global $wp_widget_factory;
$widget_obj = $wp_widget_factory->widgets[$widget];
if ( !is_a($widget_obj, 'WP_Widget') )
return;
$before_widget = sprintf('<div class="widget %s">', $widget_obj->widget_options['classname'] );
$default_args = array( 'before_widget' => $before_widget, 'after_widget' => "</div>", 'before_title' => '<h2 class="widgettitle">', 'after_title' => '</h2>' );
$args = wp_parse_args($args, $default_args);
$instance = wp_parse_args($instance);
do_action( 'the_widget', $widget, $instance, $args );
$widget_obj->_set(-1);
$widget_obj->widget($args, $instance);
}
WP Trac GitHub Bitbucket
Link here
-
URL
http://queryposts.com/function/the_widget/ -
HTML
<a href='http://queryposts.com/function/the_widget/'>the_widget()</a> -
Markdown
[the_widget()](http://queryposts.com/function/the_widget/) -
BBCode
[url=http://queryposts.com/function/the_widget/]the_widget()[/url]