get_sidebar
云策文档标注
概述
get_sidebar 是一个 WordPress 动作钩子,在加载侧边栏模板文件之前触发。它允许开发者自定义侧边栏的加载过程。
关键要点
- 钩子名称:get_sidebar
- 触发时机:在侧边栏模板文件加载之前
- 参数:$name(字符串或 null,指定侧边栏文件名,null 表示默认侧边栏),$args(数组,传递给侧边栏模板的额外参数)
- 源调用:do_action( 'get_sidebar', $name, $args )
- 相关函数:get_sidebar(),用于加载侧边栏模板
- 版本历史:引入于 2.2.0,$name 参数添加于 2.8.0,$args 参数添加于 5.5.0
原文内容
Fires before the sidebar template file is loaded.
Parameters
$namestring|null-
Name of the specific sidebar file to use. Null for the default sidebar.
$argsarray-
Additional arguments passed to the sidebar template.
Source
do_action( 'get_sidebar', $name, $args );