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函数讲解》的一些看法。更多内容请查看本栏目更多内容!
插件称号:多备份 插件下载:http://www.dbfen.com/tools/dbfen_wordpress_20141112.zip 第1步下载紧缩包后...
导航菜单 导航菜单早已 "深化民意", 在博客上的使用日益重要且多样. 从本文开端, 我将展开几个对于 WordPre...
wp_title 函数在 WordPress 中是用来显示文章、页面、分类等等等等题目的一个函数,但在首页索引,该函数将...
穆童博客应用的是Wordpress顺序,上次在改换了效劳器之后不知为何一切新评论的IP地址都显示为127.0.0.1。刚...
在WordPress中时常存在某些文章不需求题目的状况,特地是在一些集体网站,他们经常应用一些不需求题目的pos...
WordPress是当今最盛行的建站博客顺序,性能弱小,上手容易,各种主题和插件等应有尽有,无关Wordpress的相...