get_sidebar()
get_sidebar( string $name = null ) 加载边栏模板。Load sidebar …
get_sidebar( string $name = null )
加载边栏模板。
Load sidebar template.
目录锚点:#说明#参数#返回#源码#笔记
说明(Description)
包含主题的侧边栏模板,或者如果指定了名称,则将包含专门的侧边栏。
对于参数,如果文件名为“sidebar-特殊.php然后指定“特殊”。
参数(Parameters)
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| $name | (string) | 可选 | 专业侧边栏的名称。 |
返回(Return)
无返回值
源码(Source)
/**
* Load sidebar template.
*
* Includes the sidebar template for a theme or if a name is specified then a
* specialised sidebar will be included.
*
* For the parameter, if the file is called "sidebar-special.php" then specify
* "special".
*
* @since 1.5.0
*
* @param string $name The name of the specialised sidebar.
*/
function get_sidebar( $name = null ) {
/**
* Fires before the sidebar template file is loaded.
*
* The hook allows a specific sidebar template file to be used in place of the
* default sidebar template file. If your file is called sidebar-new.php,
* you would specify the filename in the hook as get_sidebar( 'new' ).
*
* @since 2.2.0
* @since 2.8.0 $name parameter added.
*
* @param string $name Name of the specific sidebar file to use.
*/
do_action( 'get_sidebar', $name );
$templates = array();
$name = (string) $name;
if ( '' !== $name )
$templates[] = "sidebar-{$name}.php";
$templates[] = 'sidebar.php';
// Backward compat code will be removed in a future release
if ('' == locate_template($templates, true))
load_template( ABSPATH . WPINC . '/theme-compat/sidebar.php');
}| 更新版本 | 源码位置 | 使用 | 被使用 |
|---|---|---|---|
| 1.5.0 | wp-includes/general-template.php:92 | 0 | 3 |
笔记(Notes)
简单调用
多边栏
简单404页
类别:WordPress 函数手册、
本文收集自互联网,转载请注明来源。
如有侵权,请联系 wper_net@163.com 删除。




还没有任何评论,赶紧来占个楼吧!