5ucms论坛

标题: register_sidebar()函数 注册一个单独的侧边栏区域和返回ID [打印本页]

作者: admin    时间: 2021-5-30 15:49
标题: register_sidebar()函数 注册一个单独的侧边栏区域和返回ID
  1. <?php register_sidebar(
  2.     array(
  3.         'name'          => '侧边栏',
  4.         'id'            => 'unique-sidebar-id',
  5.         'description'   => '',
  6.         'class'         => '',
  7.         'before_widget' => '<div class="s-con text-center">',
  8.         'after_widget'  => '</div>',
  9.         'before_title'  => '<h2 class="widgettitle">',
  10.         'after_title'   => '</h2>'
  11.     )
  12. ); ?>
复制代码

参数

name – 侧边栏的名字(默认是 ‘Sidebar’ 加 数字 ID)
id – 侧边栏 ID,必须全部小写,不带空格(默认是一个自动递增的数字 ID)
description – 用来说明侧边栏是什么,在哪里显示的文字。会在小工具管理界面显示。(默认为空)
class – 分配到小工具 HTML输出中的CSS选择器名字(默认为空)
before_widget – 在每个小工具前面输出的 HTML代码(默认: ‘<li id=”%1$s” class=”widget %2$s”>’)
after_widget – 在每个小工具后面输出的 HTML代码(默认: “</li>”)
before_title – 在标题前输出的 HTML代码(默认: <h2 class=”widgettitle”>)
after_title – 在标题后输出的 HTML代码(默认:”</h2>”)





欢迎光临 5ucms论坛 (http://bbs.5ucms.com/) Powered by Discuz! X3.2