register_sidebar()(创立侧边栏)
建设一个侧边栏,用来搁置小工具。这个函数应用的时分请放在一个函数里,挂载到 “widgets_init” 钩子。
用法
register_sidebar( $args );
参数
$args
(字符串 | 数组)(可选)要创立的侧边栏的参数。
默许值:
$args = array( 'name' => __( 'Sidebar name', 'theme_text_domain' ), 'id' => 'unique-sidebar-id', 'description' => '', 'class' => '', 'before_widget' => '<li id="%1" class="widget %2">', 'after_widget' => '</li>', 'before_title' => '<h2 class="widgettitle">', 'after_title' => '</h2>' );
数组参数引见:
例子
register_sidebar( array( 'name' => __( '左边的侧边栏' ), 'id' => 'sidebar-1', 'description' => __( '右侧边栏的小工具。' ), 'before_title' => '<h3 class="title">', 'after_title' => '</h3 class="title">', ));
其它
该函数位于:wp-includes/widgets.php
get_sidebar()(获取侧边栏)
get_sidebar() 用来引入侧边栏模板。假如指定称号则引入以后主题根目录的 sidebar-{name}.php 文件,不指定则引入以后主题根目录的 sidebar.php 文件,假如文件不存在则引入 wp-includes/theme-compat/sidebar.php 文件。
用法
get_sidebar( $name );
参数
$name
(字符串)(可选)引入模板的称号,假如指定则引入以后主题根目录的 sidebar-{$name}.php 文件。
默许值:None
例子
下边的代码将引入以后主题根目录的 sidebar.php 文件:
<?php get_sidebar(); ?>
下边的代码将引入以后主题根目录的 sidebar-left.php 文件:
<?php get_sidebar( 'left' ); ?>
下边的例子辨别引入了左侧边栏(sidebar-left.php)和右侧边栏(sidebar-right.php):
<?php get_header(); ?> <?php get_sidebar( 'left' ); ?>
内容内容
<?php get_sidebar( 'right' ); ?> <?php get_footer(); ?>
其它
此函数位于:wp-includes/general-template.php
以上就是安达网络工作室关于《WordPress中用于创建以及获取侧边栏的PHP函数讲解》的一些看法。更多内容请查看本栏目更多内容!
本文实例讲述了WordPress如何完成用户主动登录性能的办法,其实就是很简略的让用户记住登录明码了,下次主动登...
然而固定衔接假如不必postid命名的话兴许发现不了,然而大葱不断应用的就是这种固定链接。假如你网速不佳的...
确定要放在Head局部 ? 现实上最好的状况是,js文件都不要在<head>局部进行加载,否则会影响到head局部的...
很多冤家刚建设博客的时分都是采纳国际优秀的博客零碎:Z-BLOG,用一段工夫当时很多人都想转移到wordpress,...
本文实例讲述了WordPress后盾删除不需求的侧边栏菜双方法。分享给大家供大家参考。 详细完成办法是在以后主...
此时假如上传一个不在预约义的平安扩大名列表,如.lrc,会报错: File type does not meet security guidel...