函数原型:
get_sidebar( string $name = null, array $args = array() ): void|false
包含主题的侧边栏模板,或者如果指定了名称,则将包含专门的侧边栏。对于参数 $name,如果文件名为“sidebar-special.php”,则应指定 $name 为:“special”。
参数说明:
$name,指定 sidebar 模板的名称,如果为空则加载 sidebar.php。如果 $name=’special’,则加载 sidebar-specific.php 。
$args,传给 header 模板的参数。
函数源码:
function get_sidebar( $name = null, $args = array() ) {
do_action( 'get_sidebar', $name, $args );
$templates = array();
$name = (string) $name;
if ( '' !== $name ) {
$templates[] = "sidebar-{$name}.php";
}
$templates[] = 'sidebar.php';
if ( ! locate_template( $templates, true, true, $args ) ) {
return false;
}
}
包含钩子:
do_action( 'get_sidebar', string|null $name, array $args )
使用举例:
<?php if ( is_home() ) : get_sidebar( 'home' ); elseif ( is_404() ) : get_sidebar( '404' ); else : get_sidebar(); endif; ?>
上面是“wordpress建站:怎么利用get_sidebar实现加载侧边栏模板文件”的全面内容,想了解更多关于 wordpress 内容,请继续关注web建站教程。
当前网址:https://ipkd.cn/webs_4225.html
workflows工作流
文生图工作流:一幅海底睡莲,碧海蓝天comfyui工
1个黑发带着耳机项链的女孩ComfyUI工作流
树上挂着一只表情可爱的香蕉ComfyUI工作流二
在森林中心有一座蛇形的房子ComfyUI工作流
在白雪覆盖的广阔平原上两只可爱的小猫
一个穿绿衣服国风古典女孩
树上挂着一只快乐的小樱桃
一个外国人在吹奏萨克斯ComfyUI工作流
猜你喜欢
声明:本站提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请发送到邮箱:admin@ipkd.cn,我们会在看到邮件的第一时间内为您处理!

3d文字动画效果
用canvas实现画板涂鸦效果
纯css制作卡通头像(随鼠标转头)
利用canvas画几个好玩的星云物种
3d空间行走效果
jquery做一个漂亮挂墙动态时钟
3D彩色卡片
css3绘制一个会动的大嘴鸟






