Languages: English • 日本語 (Add your language)
This template tag displays an arbitrary widget outside of a sidebar. It can be used anywhere in templates.
<?php the_widget( $widget, $instance, $args ); ?>
Display a monthly archive list.
<?php the_widget( 'WP_Widget_Archives', $instance, $args ); ?>
widget_archive
__('Archives')
Default usage:
<?php the_widget( 'WP_Widget_Archives' ); ?>
Display drop-down list:
<?php the_widget( 'WP_Widget_Archives', 'dropdown=1' ); ?>
Displays a Calendar.
<?php the_widget( 'WP_Widget_Calendar', $instance, $args ); ?>
widget_calendar
Default usage:
<?php the_widget( 'WP_Widget_Calendar' ); ?>
Displays a list of categories.
<?php the_widget( 'WP_Widget_Categories', $instance, $args ); ?>
widget_categories
__( 'Categories' )
Default usage:
<?php the_widget('WP_Widget_Categories'); ?>
Display a dropdown list with number of posts.
<?php the_widget( 'WP_Widget_Categories', 'dropdown=1&count=1' ); ?>
Displays arbitrary HTML.
<?php the_widget( 'WP_Widget_Custom_HTML', $instance, $args ); ?>
widget_custom_html
Default usage:
<?php the_widget('WP_Widget_Custom_HTML', array('title' => 'Example', 'content' => '<p>Basic example.</p>')); ?>
Displays a list of links (blogroll) in categories.
<?php the_widget( 'WP_Widget_Links', $instance, $args ); ?>
alt
attribute. The show_name parameter. Default: falseDefault usage:
<?php the_widget( 'WP_Widget_Links' ); ?>
Display lists in category IDs 2 or 3:
<?php the_widget( 'WP_Widget_Links', 'category=2,3' ); ?>
Display site meta. (Log in/out, admin, feed and WordPress links )
<?php the_widget( 'WP_Widget_Meta', $instance, $args ); ?>
widget_meta
__( 'Meta' )
Default usage:
<?php the_widget( 'WP_Widget_Meta' ); ?>
Display a list of Pages.
<?php the_widget( 'WP_Widget_Pages', $instance, $args ); ?>
widget_pages
__( 'Pages' )
menu_order
Default usage:
the_widget( 'WP_Widget_Pages' );
the_widget('WP_Widget_Pages', 'title=Contents&sortby=post_modified', 'before_title=<h3>&after_title=</h3>');
Display to a list of recent comments.
<?php the_widget( 'WP_Widget_Recent_Comments', $instance, $args ); ?>
widget_recent_comments
__( 'Recent Comments' )
Default usage:
<?php the_widget( 'WP_Widget_Recent_Comments' ); ?>
Display to a list of recent posts.
<?php the_widget( 'WP_Widget_Recent_Posts', $instance, $args ); ?>
widget_recent_entries
__('Recent Posts')
Default usage:
<?php the_widget( 'WP_Widget_Recent_Posts' ); ?>
Display a list of entries from any RSS or Atom feed.
<?php the_widget( 'WP_Widget_RSS', $instance, $args ); ?>
Default usage:
<?php the_widget( 'WP_Widget_RSS' ); ?>
<?php the_widget( 'WP_Widget_Search', $instance, $args ); ?>
widget_search
Default usage:
<?php the_widget( 'WP_Widget_Search' ); ?>
<?php the_widget( 'WP_Widget_Tag_Cloud', $instance, $args ); ?>
__( 'Tags' )
post_tag
Default usage:
<?php the_widget( 'WP_Widget_Tag_Cloud' ); ?>
<?php the_widget( 'WP_Widget_Text', $instance, $args ); ?>
widget_text
Default usage:
<?php the_widget( 'WP_Widget_Text' ); ?>
Display custom widget in template.
<?php the_widget( 'My_Custom_Widget', $instance, $args ); ?>
Default usage:
class My_Custom_Widget extends WP_Widget
{
/* your code* /
}
<?php the_widget( 'My_Custom_Widget' ); ?>
the_widget() is located in wp-includes/widgets.php
wp-includes/default-widgets.php
- Source code for the widgets included in WordPress Core.Widgets: is_active_widget(), the_widget(), register_widget(), unregister_widget(), wp_register_widget_control(), wp_unregister_widget_control(), wp_convert_widget_settings(), wp_get_widget_defaults(), wp_widget_description()