the_widget()显示一个小工具/侧板栏

目录

描述

This template tag displays an arbitrary widget outside of a sidebar. It can be used anywhere in templates.

the_widget() 描述

用法

 <?php the_widget$widget$instance$args ); ?> 

the_widget() 用法

参数

$widget

(string) (必填) The widget's PHP class name. The classes for the widgets included with WordPress are:

  • WP_Widget_Archives -- Archives
  • WP_Widget_Calendar -- Calendar
  • WP_Widget_Categories -- Categories
  • WP_Widget_Links -- Links
  • WP_Widget_Meta -- Meta
  • WP_Widget_Pages -- Pages
  • WP_Widget_Recent_Comments -- Recent Comments
  • WP_Widget_Recent_Posts -- Recent Posts
  • WP_Widget_RSS -- RSS
  • WP_Widget_Search -- Search (a search from)
  • WP_Widget_Tag_Cloud -- Tag Cloud
  • WP_Widget_Text -- Text
  • WP_Nav_Menu_Widget

默认值: None

$instance

(array|string) (可选) The widget's instance settings. Either an array or query-style string. See each widget below for examples.

默认值: array()

$args

(array|string) (可选) The widget's sidebar args. Either an array or query-style string. If empty, it defaults to:

before_widget

(string) the text or HTML befor the widget.

Default: <div class="widget {widget's classname}">

after_widget

(string) the text or HTML after the widget.

Default: </div>

before_title

(string) the text or HTML before the widget's title.

Default: <h2 class="widgettitle">

after_title

(string) the text or HTML after the widget's title.

Default: </h2>

默认值: array()

the_widget() 参数

注意

  • 使用到: global $wp_widget_factory - To retrieve the widget object.
  • 使用到: do_action() - 调用 'the_widget' with $widget, $instance and $args.

the_widget() 注意

历史

the_widget() 历史

源文件

the_widget() 函数的代码位于 wp-includes/widgets.php

the_widget() 源文件

相关